diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-12 09:23:23 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-12 09:23:23 (GMT) |
commit | 0cc7fd3498bf486b2eb5bc20a67f5671f2830097 (patch) | |
tree | 9ec3570dae1bac7204826279ecb7a2007f7a8ffe /tests/socket.test | |
parent | ea8cb9b7bbc9be827be479c3aad3700cbe5774a4 (diff) | |
download | tcl-0cc7fd3498bf486b2eb5bc20a67f5671f2830097.zip tcl-0cc7fd3498bf486b2eb5bc20a67f5671f2830097.tar.gz tcl-0cc7fd3498bf486b2eb5bc20a67f5671f2830097.tar.bz2 |
Fix sporadically errors in zlib-8.x and socket tests, cherry-picked from "fix-1997007" branch. Credit to "sebres"!
Diffstat (limited to 'tests/socket.test')
-rw-r--r-- | tests/socket.test | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/socket.test b/tests/socket.test index d43c41c..a3e5704 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -69,7 +69,22 @@ testConstraint exec [llength [info commands exec]] # Produce a random port number in the Dynamic/Private range # from 49152 through 65535. -proc randport {} { expr {int(rand()*16383+49152)} } +proc randport {} { + # firstly try dynamic port via server-socket(0): + set port 0x7fffffff + catch { + set port [lindex [fconfigure [set s [socket -server {} 0]] -sockname] 2] + close $s + } + while {[catch { + close [socket -server {} $port] + } msg]} { + if {[incr i] > 1000} {return -code error "too many iterations to get free random port: $msg"} + # try random port: + set port [expr {int(rand()*16383+49152)}] + } + return $port +} # Test the latency of tcp connections over the loopback interface. Some OSes # (e.g. NetBSD) seem to use the Nagle algorithm and delayed ACKs, so it takes |