|
2001-04-01
| ||
| 01:47 | • Ticket [218467ffff] Server Socket Errors status still Closed with 3 other ch... artifact: 47464fff7b user: dgp | |
|
2000-10-26
| ||
| 08:22 | • Closed ticket [218467ffff]. artifact: 98030fc811 user: welch | |
| 01:00 | • New ticket [218467ffff]. artifact: 94eb521008 user: nobody | |
Server Socket Errors
Closed / Fixed218467ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:00:49
OriginalBugID: 628 Bug Version: 8.0 SubmitDate: '1998-05-25' LastModified: '1999-09-13' Severity: LOW Status: Released Submitter: hershey ChangedBy: hobbs OS: Windows NT OSVersion: 4.0 Machine: NA FixedDate: '1999-09-13' FixedInVersion: 8.2 ClosedDate: '2000-10-25' [email protected] Hello, I am having a problem dealing with socket errors. I took an example from the Welch book and implemented it on Win NT 4.0 using tclsh80.exe. I start my TCL program, and then I connect to it using telnet. I type "Hi" and Enter which it echoes back as designed, but when I use the telnet program to forcefully close the socket, I get the following error from tchsh80.exe: Reading socket <--- last line of text from my program bgerror failed to handle background error. Original error: error writing "sock440": connection reset by peer Error in bgerror: invalid command name "bgerror" It looks like my catch and eof logic is not detecting that the socket has closed. Can someone show me how to reliably trap for these errors? Thanx much, code follows. ************* Code Below ************ proc Echo_Server {port} { global echo set echo [socket -server EchoAccept $port] } proc EchoAccept {sock addr port} { puts "Accept $sock from $addr port $port" fconfigure $sock -buffering line fileevent $sock readable [list Echo $sock] } proc Echo {sock} { global echo global forever puts "Reading socket" if {[eof $sock] || [catch {gets $sock line}]} { # end of file or abnormal connection drop puts "Abnormal socket end" close $sock } else { if {[string compare $line "quit"] == 0} { puts "Received close command" close $sock # close main socket so no more incoming close $echo set forever 1 } else { if {[string compare $line "bye"] == 0} { puts "Received bye command" # close main socket so no more incoming close $sock } else { puts $sock $line puts "READ: $line" } } } } set forever 0 Echo_Server 2546 vwait forever Puts "exiting program" Try instead with the eof code: if {[eof $sock] || ([gets $sock line] == -1)} { SocketShutdown $sock return } And better yet, upgrade to 8.2 which has improved socket support on Windows. -- 09/13/1999 hobbs
welch Closed ticket [218467ffff].
[History diff]2000-10-26 08:22:17
dgp Ticket [218467ffff]: 3 changes
[History diff]2001-04-01 01:47:51
Log in (anonymous is fine) to add a comment.