]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 217: fix hfaxd to reuse the TCP port if current client connections exist
authorLee Howard <faxguy@howardsilvan.com>
Tue, 16 Dec 2003 18:39:15 +0000 (18:39 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Tue, 16 Dec 2003 18:39:15 +0000 (18:39 +0000)
hfaxd/InetFaxServer.c++

index 39c8fd30d403a2c59c2c42ecd5dd1db588244f92..96baca9489e9e992838329e9b8a3ae2dbc060a5c 100644 (file)
@@ -63,10 +63,14 @@ InetSuperServer::startServer(void)
                sin.sin_port = htons(FAX_DEFPORT);
        } else
            sin.sin_port = sp->s_port;
-       if (Socket::bind(s, &sin, sizeof (sin)) >= 0) {
-           (void) listen(s, getBacklog());
-           Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
-           return (true);                              // success
+       { int on = 1;
+           if (Socket::setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) >= 0) {
+               if (Socket::bind(s, &sin, sizeof (sin)) >= 0) {
+                   (void) listen(s, getBacklog());
+                   Dispatcher::instance().link(s, Dispatcher::ReadMask, this);
+                   return (true);                              // success
+               }
+           }
        }
        Sys::close(s);
        logError("HylaFAX %s: bind (port %u): %m",