- set port 11111
- while 1 {
- puts "Starting test server at port $port"
- if {[catch {socket -server accept_test_clients $port} e]} {
- if {[string match {*address already in use*} $e]} {
- if {$port == 20000} {
- puts "Can't find an available TCP port for test server."
- exit 1
- } else {
- incr port
- }
- } else {
- puts "Fatal error starting test server: $e"
- exit 1
- }
- } else {
- break
- }
- }
+ set port [find_available_port 11111]
+ puts "Starting test server at port $port"
+ socket -server accept_test_clients $port