Skip to content

Instantly share code, notes, and snippets.

@kobi2187
Created January 19, 2019 12:06
Show Gist options
  • Save kobi2187/bfe1fa6a5dc131a17d4fe13123f92cd5 to your computer and use it in GitHub Desktop.
Save kobi2187/bfe1fa6a5dc131a17d4fe13123f92cd5 to your computer and use it in GitHub Desktop.
connects to an open port
# purpose:
# check that we're able to connect to site:port
import uri, net, system
proc check_site*(host: Uri, port: Port): bool {.raises: [OSError,
SslError].} =
var socket = newSocket()
try:
socket.connect(host.hostname, port)
return true
# except OSError:
except:
echo getCurrentExceptionMsg()
echo getCurrentException().getStackTrace
return false
finally:
socket.close
@kobi2187
Copy link
Author

compile with -d:ssl

@kobi2187
Copy link
Author

index out of bounds: (i:-1) <= (n:-1)
main.nim(58) main
main.nim(56) main
ctrl.nim(55) start
manage_network.nim(9) check_site
net.nim(1582) connect
nativesockets.nim(266) getAddrInfo
oserr.nim(62) raiseOSError
system.nim(3831) []
system.nim(3016) sysFatal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment