mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +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
eef00d5ff0
commit
beb412e72d
3 changed files with 40 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-11-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* unix/NSStream.m:
|
||||
* win32/NSStreamWin32.m:
|
||||
Re-use socket ports so that programs can start up again immediately
|
||||
after they have shut down.
|
||||
|
||||
2006-11-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSCalendarDate.m: Fix to parse timezone names as being
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -2213,10 +2213,22 @@ done:
|
|||
|
||||
- (void) open
|
||||
{
|
||||
int bindReturn = bind(_sock, [self serverAddr], [self sockLen]);
|
||||
int listenReturn = listen(_sock, SOCKET_BACKLOG);
|
||||
int bindReturn;
|
||||
int listenReturn;
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
int status = 1;
|
||||
|
||||
if (bindReturn < 0 || listenReturn)
|
||||
/*
|
||||
* 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!
|
||||
*/
|
||||
setsockopt(_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status));
|
||||
#endif
|
||||
bindReturn = bind(_sock, [self serverAddr], [self sockLen]);
|
||||
listenReturn = listen(_sock, SOCKET_BACKLOG);
|
||||
if (bindReturn < 0 || listenReturn < 0)
|
||||
{
|
||||
[self _recordError];
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue