From c71811ceb4e5647304eed264043d40b2fddf7517 Mon Sep 17 00:00:00 2001 From: teodor Date: Wed, 29 Sep 2004 16:00:35 +0000 Subject: [PATCH] add reuse --- tcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tcp.c b/tcp.c index 525a57e..6833be2 100644 --- a/tcp.c +++ b/tcp.c @@ -95,7 +95,7 @@ setlinger( TC_Connection *cs ) { u_int32_t TC_ClientInitConnection(TC_Connection *cs, char *name, u_int32_t port) { - int flags; + int flags, val=1; cs = TC_fillConnection(cs, name, port); @@ -104,6 +104,11 @@ TC_ClientInitConnection(TC_Connection *cs, char *name, u_int32_t port) { tlog(TL_CRIT|TL_EXIT,"socket4: %s:%d - %s",inet_ntoa(cs->serv_addr.sin_addr), ntohs(cs->serv_addr.sin_port),strerror(errno)); + if (setsockopt(cs->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { + tlog(TL_CRIT|TL_EXIT, "socketsockopt failed: %s", strerror(errno)); + return CS_ERROR; + } + if ((flags=fcntl(cs->fd,F_GETFL,0)) == -1) tlog(TL_ALARM,"fcntl F_GETFL - %s",strerror(errno)); if (fcntl(cs->fd,F_SETFL,flags|O_NDELAY) < 0 ) -- 2.46.1