Fix connection refused check.

This commit is contained in:
cheatfate 2018-10-25 13:52:56 +03:00
parent a4c27806ea
commit 0ea8e65b2c
1 changed files with 4 additions and 5 deletions

View File

@ -614,13 +614,12 @@ proc testConnectionRefused(address: TransportAddress): Future[bool] {.async.} =
try:
var transp = await connect(address)
except TransportOsError as e:
let ecode = int(e.code)
when defined(windows):
if address.family == AddressFamily.Unix:
result = (int(e.code) == ERROR_FILE_NOT_FOUND)
else:
result = (int(e.code) == ERROR_CONNECTION_REFUSED)
result = (ecode == ERROR_FILE_NOT_FOUND) or
(ecode == ERROR_CONNECTION_REFUSED)
else:
result = (int(e.code) == ECONNREFUSED)
result = (ecode == ECONNREFUSED) or (ecode == ENOENT)
when isMainModule:
const