diff options
-rw-r--r-- | test/testclnt.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua index 5f366b2..348439a 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
@@ -365,14 +365,16 @@ end | |||
365 | ------------------------------------------------------------------------ | 365 | ------------------------------------------------------------------------ |
366 | function connect_timeout() | 366 | function connect_timeout() |
367 | io.write("connect with timeout (if it hangs, it failed): ") | 367 | io.write("connect with timeout (if it hangs, it failed): ") |
368 | local t = socket.time() | ||
369 | local c, e = socket.tcp() | 368 | local c, e = socket.tcp() |
370 | assert(c, e) | 369 | assert(c, e) |
371 | c:settimeout(0.1) | 370 | c:settimeout(0.1) |
372 | local r, e = c:connect("ibere.tecgraf.puc-rio.br", 80) | 371 | ip = socket.dns.toip("ibere.tecgraf.puc-rio.br") |
372 | if not ip then return end | ||
373 | local t = socket.time() | ||
374 | local r, e = c:connect(ip, 80) | ||
373 | assert(not r, "should not connect") | 375 | assert(not r, "should not connect") |
374 | assert(e == "timeout", e) | 376 | assert(e == "timeout", e) |
375 | assert(socket.time() - t < 2, "took to long to give up") | 377 | assert(socket.time() - t < 2, "took too long to give up.") |
376 | c:close() | 378 | c:close() |
377 | end | 379 | end |
378 | 380 | ||