Artifacts Associated With Ticket 218945
Ticket change [ad13b01c0a] (rid 101410) by nobody on 2000-10-26 01:08:27:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 2868 Bug Version: 8.2 SubmitDate: '1999-09-23' LastModified: '1999-09-29' Severity: SER Status: Released Submitter: techsupp ChangedBy: hobbs OS: Windows 95 Machine: X86 FixedDate: '1999-09-28' FixedInVersion: 8.2.1 ClosedDate: '2000-10-25' Name: Don Porter ReproducibleScript: #!/bin/sh # FILE: async # Usage: async <host> <port> # exec tclsh "$0" ${1+"$@"} proc AsyncConnect {host port} { puts "creating socket..." set s [socket -async $host $port] puts "socket created" fileevent $s writable [list VerifyConnection $s $host $port] } proc VerifyConnection {s host port} { global connected fileevent $s writable {} # If there's an error condition on the socket (failure to connect), # then [fconfigure -error] should provide an error message # set msg [fconfigure $s -error] if {![string match {} $msg]} { puts "Connection to $host:$port failed: $msg" set connected 0 catch {close $s} return } # Connection reportedly successful. At this point we normally # configure the socket for whatever communications we want and # set up fileevent handlers to manage protocols over the socket. # # Here, as a simple check, print out the peername information # as a check of a good connection. If we really are connected, # we print information about the far end of the connection. If # not, print an error message indicating that Tcl's fileevent, # fconfigure, and socket are not working as advertised. # if {[catch {fconfigure $s -peername} peerInfo]} { puts "Tcl is broken: $peerInfo" } else { puts "Connected: $peerInfo" } set connected 1 close $s } proc tick {} { # Demonstrate event loop is active, and provide eventual timeout global tick connected incr tick puts "tick $tick" if {$tick >= 6000} {set connected 0; return} after 10 tick } set connected 0 set tick 0 tick eval AsyncConnect $argv vwait connected # END FILE: async ObservedBehavior: C:> tclsh82 async www.w3.org 90 tick 1 creating socket... socket created tick 2 ... tick 895 Tcl is broken: can't get peername: socket is not connected DesiredBehavior: If the socket is not connected, I expect [fconfigure $socket -error] to return a non-empty error message, so that failure to connect can be detected by the callback routine after a [socket -async $host $port]. Currently it appears the only way to check the socket for a successful connection is to catch [fconfigure $socket -peername]. That is an expensive operation which may block for awhile. If I didn't mind blocking, I wouldn't be using [socket -async] in the first place. I am moving this to either fixed (or closed) for 8.2.1, because it gives me: (tkcon) 51 % AsyncConnect pop 90 creating socket... socket created ## some waiting occurs here Connection to pop:90 failed: connection refused Which seems to be what the user wanted. This is on NT/SP4. -- 09/28/1999 hobbs Further notes from the user indicate that this works as expected for 98 and NT, but not 95. This could either be a Tcl or MS problem, but not high priority for us to examine further. -- 09/29/1999 hobbs - foundin initialized to: "obsolete: 8.2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "[fconfigure $socket -error] broken"
- type initialized to: "Bug"
Ticket change [8d0007fde0] (rid 127842) by welch on 2000-10-26 08:32:14:
- closedate changed to: "2000-10-26T01:32:14"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [5fdd80d4ea] (rid 115894) by dgp on 2001-04-19 03:31:29:
- closedate changed to: "2001-04-18T20:31:29"
- closer changed to: "dgp"
- resolution changed to: "Wont Fix"
- subsystem changed to: "27. Channel Types"