summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sockutil.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sockutil.c b/src/sockutil.c
index 9465e0877..b28989bdb 100644
--- a/src/sockutil.c
+++ b/src/sockutil.c
@@ -559,6 +559,7 @@ int conn(const char *host, int port, const char *lhost, int lport)
#endif
struct sockaddr_in sa, lsa;
ano_socket_t sock;
+ int sockopt = 1;
memset(&lsa, 0, sizeof(lsa));
if (lhost) {
@@ -598,6 +599,11 @@ int conn(const char *host, int port, const char *lhost, int lport)
if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0)
return -1;
+ if (setsockopt
+ (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &sockopt,
+ sizeof(int)) < 0)
+ alog("debug: couldn't set SO_REUSEADDR on socket");
+
if ((lhost || lport)
&& bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) {
int errno_save = ano_sockgeterr();