From 1542b79f05d4bb6a6f1d330270c195b711fedd28 Mon Sep 17 00:00:00 2001 From: Janneke Nieuwenhuizen Date: Fri, 11 Aug 2023 13:37:55 +0200 Subject: [PATCH] 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. --- 8sync/systems/irc.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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") -- 2.31.1