Add checks for invalid socket when creating sockets.

This commit is contained in:
Dominik Picheta 2014-04-15 13:51:25 +01:00
commit 21d0cc8cdf
7 changed files with 9 additions and 0 deletions

View file

@ -249,6 +249,7 @@ proc reconnect*(irc: PIRC, timeout = 5000) =
if secSinceReconnect < timeout:
sleep(timeout - secSinceReconnect)
irc.sock = socket()
if irc.sock == InvalidSocket: osError(osLastError())
irc.connect()
irc.lastReconnect = epochTime()
@ -274,6 +275,7 @@ proc irc*(address: string, port: TPort = 6667.TPort,
result.messageBuffer = @[]
result.status = SockIdle
result.sock = socket()
if result.sock == InvalidSocket: osError(osLastError())
proc processLine(irc: PIRC, line: string): TIRCEvent =
if line.len == 0: