summaryrefslogtreecommitdiffstats
path: root/tests/socket.test
diff options
context:
space:
mode:
authormax <max@tclers.tk>2011-05-30 18:04:42 (GMT)
committermax <max@tclers.tk>2011-05-30 18:04:42 (GMT)
commit2f67cb7c57ed82cb80c4e9a3905850869b9c63c4 (patch)
tree04193c695f37b4d4c11036c9232cb67efb98f576 /tests/socket.test
parent19755ae8971d97cfc092add10ceed6ab40f011bd (diff)
downloadtcl-2f67cb7c57ed82cb80c4e9a3905850869b9c63c4.zip
tcl-2f67cb7c57ed82cb80c4e9a3905850869b9c63c4.tar.gz
tcl-2f67cb7c57ed82cb80c4e9a3905850869b9c63c4.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.test39
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