Ensure that REUSEADDR flag is only applied for TCP

master
Aadhavan Srinivasan 9 months ago
parent c490eaa301
commit 3d0aeac943

@ -52,10 +52,11 @@ SOCKET create_socket(int network, char transport) {
int newSock = socket(domain,type,0); int newSock = socket(domain,type,0);
/* Set REUSEADDR flag, allowing program to be run twice */ /* Set REUSEADDR flag for TCP, allowing program to be run twice */
int set_opt = 1; if (transport == ES_UDP) {
setsockopt(newSock, SOL_SOCKET, SO_REUSEADDR, (char *)&set_opt, sizeof(set_opt)); int set_opt = 1;
setsockopt(newSock, SOL_SOCKET, SO_REUSEADDR, (char *)&set_opt, sizeof(set_opt));
}
return newSock; return newSock;
} }

Loading…
Cancel
Save