341 |
|
|
342 |
|
|
343 |
/** |
/** |
344 |
* Create a blocking server socket and bind it to the specified local |
* Create a non-blocking server socket and bind it to the specified local |
345 |
* port number, with the specified backlog. Set a socket option to |
* port number, with the specified backlog. Set a socket option to |
346 |
* make the port reusable again. If a bind address is given the socket |
* make the port reusable again. If a bind address is given the socket |
347 |
* will only accept connect requests to this addresses. If the bind |
* will only accept connect requests to this addresses. If the bind |
380 |
if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof(int)) < 0) |
if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof(int)) < 0) |
381 |
goto error; |
goto error; |
382 |
|
|
383 |
|
if(! set_noblock(s)) |
384 |
|
goto error; |
385 |
|
|
386 |
if(bind(s, (struct sockaddr *)&myaddr, sizeof(struct sockaddr_in)) < 0) |
if(bind(s, (struct sockaddr *)&myaddr, sizeof(struct sockaddr_in)) < 0) |
387 |
goto error; |
goto error; |
388 |
|
|