Bleh
[doldaconnect.git] / daemon / net.c
index 1eeaff1..6acd2d0 100644 (file)
@@ -574,6 +574,7 @@ struct socket *netcslisten(int type, struct sockaddr *name, socklen_t namelen, v
 struct socket *netcslistenlocal(int type, struct sockaddr *name, socklen_t namelen, void (*func)(struct socket *, struct socket *, void *), void *data)
 {
     struct socket *sk;
+    int intbuf;
     
     /* I don't know if this is actually correct (it probably isn't),
      * but since, at on least Linux systems, PF_* are specifically
@@ -584,6 +585,11 @@ struct socket *netcslistenlocal(int type, struct sockaddr *name, socklen_t namel
     if((sk = mksock(name->sa_family, type)) == NULL)
        return(NULL);
     sk->state = SOCK_LST;
+    if(confgetint("net", "reuseaddr"))
+    {
+       intbuf = 1;
+       setsockopt(sk->fd, SOL_SOCKET, SO_REUSEADDR, &intbuf, sizeof(intbuf));
+    }
     if(bind(sk->fd, name, namelen) < 0)
     {
        putsock(sk);