Skip to content
Snippets Groups Projects
Commit fa78d3b6 authored by rswindell's avatar rswindell
Browse files

Setting the SO_REUSEADDR socket option on UDP sockets before initial bind

(hopefully fixing problem with re-binding UDP sockets).
parent a3340b6b
No related branches found
No related tags found
No related merge requests found
......@@ -1111,10 +1111,23 @@ void DLLCALL services_thread(void* arg)
if((socket = open_socket(
(service[i].options&SERVICE_OPT_UDP) ? SOCK_DGRAM : SOCK_STREAM))
==INVALID_SOCKET) {
lprintf("!ERROR %d opening socket", ERROR_VALUE);
lprintf("!ERROR %d opening %s socket"
,ERROR_VALUE, service[i].protocol);
cleanup(1);
return;
}
if(service[i].options&SERVICE_OPT_UDP) {
/* We need to set the REUSE ADDRESS socket option */
optval=TRUE;
if(setsockopt(socket,SOL_SOCKET,SO_REUSEADDR
,(char*)&optval,sizeof(optval))!=0) {
lprintf("%04d !ERROR %d setting %s socket option"
,socket, ERROR_VALUE, service[i].protocol);
close_socket(socket);
continue;
}
}
memset(&addr, 0, sizeof(addr));
addr.sin_addr.s_addr = htonl(startup->interface_addr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment