Artifacts Associated With Ticket 218467
Ticket change [94eb521008] (rid 106079) by nobody on 2000-10-26 01:00:49:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
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
- foundin initialized to: "obsolete: 8.0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "63. (unused)"
- title initialized to: "Server Socket Errors"
- type initialized to: "Bug"
Ticket change [98030fc811] (rid 110538) by welch on 2000-10-26 08:22:17:
- closedate changed to: "2000-10-26T01:22:17"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [47464fff7b] (rid 99670) by dgp on 2001-04-01 01:47:51:
- closedate changed to: "2001-03-31T18:47:51"
- closer changed to: "dgp"
- subsystem changed to: "27. Channel Types"