From: Janneke Nieuwenhuizen Date: Fri, 11 Aug 2023 11:37:55 +0000 (+0200) Subject: irc: Avoid connecting to #f socket, attempt reconnect. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1542b79f05d4bb6a6f1d330270c195b711fedd28;p=8sync.git irc: Avoid connecting to #f socket, attempt reconnect. * 8sync/systems/irc.scm (irc-socket-setup): Only connect to a valid socket. Retry if connecting fails. --- diff --git a/8sync/systems/irc.scm b/8sync/systems/irc.scm index aa43624..0007de8 100644 --- a/8sync/systems/irc.scm +++ b/8sync/systems/irc.scm @@ -49,11 +49,13 @@ (let* ((s (socket PF_INET SOCK_STREAM 0)) (flags (fcntl s F_GETFL)) (ip-address (inet-ntop AF_INET (car (hostent:addr-list (gethost hostname)))))) - (fcntl s F_SETFL (logior O_NONBLOCK flags)) - (connect s AF_INET - (inet-pton AF_INET ip-address) - inet-port) - s)) + (cond (s + (fcntl s F_SETFL (logior O_NONBLOCK flags)) + (connect s AF_INET (inet-pton AF_INET ip-address) inet-port) + s) + (else + (8sleep 1) + (irc-socket-setup hostname inet-port))))) (define irc-eol "\r\n")