summaryrefslogtreecommitdiffstats
path: root/tests/socket.test
diff options
context:
space:
mode:
authormax <max@tclers.tk>2014-04-08 18:00:35 (GMT)
committermax <max@tclers.tk>2014-04-08 18:00:35 (GMT)
commit9e4cc53c71c3d5416cb1e33bc5b47688ba631853 (patch)
treededb82131f5a7ed765fc88cd399d30e35c7d4e25 /tests/socket.test
parentbf345d6be59f6f513be07b6465487f137b9ac820 (diff)
downloadtcl-9e4cc53c71c3d5416cb1e33bc5b47688ba631853.zip
tcl-9e4cc53c71c3d5416cb1e33bc5b47688ba631853.tar.gz
tcl-9e4cc53c71c3d5416cb1e33bc5b47688ba631853.tar.bz2
* Give clearer names to some of the state flags and sync them with Windows where it makes sense. bug_13d3af3ad5
* Rework WaitForConnect once more to always report ENOTCONN on I/O operations on failed async sockets. * Fix synchronous connections to a server that only listens on IPv6 (or whatever comes later in the list returned by getaddrinfo(), socket-15.*) * Fix spurious writable event on async sockets (socket-14.15).
Diffstat (limited to 'tests/socket.test')
-rw-r--r--tests/socket.test34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/socket.test b/tests/socket.test
index 648ade5..5ff2109 100644
--- a/tests/socket.test
+++ b/tests/socket.test
@@ -2225,6 +2225,40 @@ test socket-14.14 {testing fileevent readable on failed async socket connect} -c
after cancel $a1
} -result readable
+test socket-14.15 {blocking read on async socket should not trigger event handlers} \
+ -constraints socket -body {
+ set s [socket -async localhost [randport]]
+ set x ok
+ fileevent $s writable {set x fail}
+ catch {read $s}
+ set x
+ } -result ok
+
+set num 0
+foreach servip {127.0.0.1 ::1 localhost} {
+ foreach cliip {127.0.0.1 ::1 localhost} {
+ if {$servip eq $cliip || "localhost" in [list $servip $cliip]} {
+ set result {-result "sock*" -match glob}
+ } else {
+ set result {
+ -result {couldn't open socket: connection refused}
+ -returnCodes 1
+ }
+ }
+ test socket-15.1.$num "Connect to $servip from $cliip" \
+ -constraints {socket supported_inet supported_inet6} -setup {
+ set server [socket -server accept -myaddr $servip 0]
+ proc accept {s h p} { close $s }
+ set port [lindex [fconfigure $server -sockname] 2]
+ } -body {
+ set s [socket $cliip $port]
+ } -cleanup {
+ close $server
+ catch {close $s}
+ } {*}$result
+ incr num
+ }
+}
::tcltest::cleanupTests
flush stdout