mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 12:16:40 +00:00
Fix bug with server sockets.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24144 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c68b761cfc
commit
07e71cbac3
3 changed files with 40 additions and 6 deletions
|
@ -1429,10 +1429,25 @@ static void setNonblocking(int fd)
|
|||
|
||||
- (void) open
|
||||
{
|
||||
int bindReturn = bind((int)(intptr_t)_loopID, [self serverAddr], [self sockLen]);
|
||||
int listenReturn = listen((intptr_t)_loopID, SOCKET_BACKLOG);
|
||||
int bindReturn;
|
||||
int listenReturn;
|
||||
|
||||
if (bindReturn < 0 || listenReturn)
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
int status = 1;
|
||||
|
||||
setsockopt((int)(intptr_t)_loopID, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&status, sizeof(status));
|
||||
#endif
|
||||
|
||||
bindReturn = bind((int)(intptr_t)_loopID, [self serverAddr], [self sockLen]);
|
||||
listenReturn = listen((intptr_t)_loopID, SOCKET_BACKLOG);
|
||||
if (bindReturn < 0 || listenReturn < 0)
|
||||
{
|
||||
[self _recordError];
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue