diff options
author | max <max@tclers.tk> | 2011-05-30 18:04:42 (GMT) |
---|---|---|
committer | max <max@tclers.tk> | 2011-05-30 18:04:42 (GMT) |
commit | 14378e297d041cfcc23eb571d9f3f3478c7f87f1 (patch) | |
tree | 04193c695f37b4d4c11036c9232cb67efb98f576 /tests/socket.test | |
parent | 1c8919b8b86f104745840c8b622305689df089d7 (diff) | |
download | tcl-14378e297d041cfcc23eb571d9f3f3478c7f87f1.zip tcl-14378e297d041cfcc23eb571d9f3f3478c7f87f1.tar.gz tcl-14378e297d041cfcc23eb571d9f3f3478c7f87f1.tar.bz2 |
* Fix setting up of [fileevent] while an async socket is still in progress
* Cache async socket errors for later use by [fconfigure -error]
* Add tests for the above
Diffstat (limited to 'tests/socket.test')
-rw-r--r-- | tests/socket.test | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/socket.test b/tests/socket.test index 1bb9b79..dd57a3d 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -1700,7 +1700,7 @@ catch {close $commandSocket} catch {close $remoteProcChan} } unset ::tcl::unsupported::socketAF -test socket-14.0 {async when server only listens on one address family} \ +test socket-14.0 {[socket -async] when server only listens on one address family} \ -constraints [list socket supported_any] \ -setup { proc accept {s a p} { @@ -1713,7 +1713,6 @@ test socket-14.0 {async when server only listens on one address family} \ set port [lindex [fconfigure $server -sockname] 2] } -body { set client [socket -async localhost $port] - # fileevent $client readable [list set x [fconfigure $client -error]] after 1000 {set x [fconfigure $client -error]} vwait x set x @@ -1721,6 +1720,42 @@ test socket-14.0 {async when server only listens on one address family} \ close $server close $client } -result ok +test socket-14.1 {[socket -async] fileevent while still connecting} \ + -constraints [list socket supported_any] \ + -setup { + proc accept {s a p} { + global x + puts $s bye + close $s + set x ok + } + set server [socket -server accept -myaddr 127.0.0.1 2222] + set port [lindex [fconfigure $server -sockname] 2] + } -body { + set client [socket -async localhost $port] + fileevent $client readable {lappend x [fconfigure $client -error]} + set after [after 1000 {set x timeout}] + vwait x + vwait x + set x + } -cleanup { + after cancel $after + close $server + close $client + } -result {ok {}} +test socket-14.2 {[socket -async] fileevent connection refused} \ + -constraints [list socket supported_any] \ + -body { + set client [socket -async localhost 0] + fileevent $client readable {set x [fconfigure $client -error]} + set after [after 1000 {set x timeout}] + vwait x + set x + } -cleanup { + after cancel $after + close $client + } -result "connection refused" + ::tcltest::cleanupTests flush stdout return |