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);
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 )