Avoid EADDRINUSE for s_server.
Submitted by: Reviewed by: PR:
This commit is contained in:
parent
a0960a1d5b
commit
cf897932ca
@ -342,6 +342,12 @@ char *ip;
|
|||||||
s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
|
s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
|
||||||
|
|
||||||
if (s == INVALID_SOCKET) goto err;
|
if (s == INVALID_SOCKET) goto err;
|
||||||
|
#if defined SOL_SOCKET && defined SO_REUSEADDR
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof i);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
|
if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
|
||||||
{
|
{
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user