31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
-
+
|
#import "OFSequencedPacketSocket+Private.h"
#import "OFData.h"
#import "OFRunLoop+Private.h"
#import "OFRunLoop.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAcceptFailedException.h"
#import "OFAcceptSocketFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFListenFailedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
-
+
-
+
-
+
|
(socklen_t)sizeof(client->_remoteAddress.sockaddr);
#if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC)
if ((client->_socket = paccept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptFailedException
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
#elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
if ((client->_socket = accept4(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptFailedException
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
#else
if ((client->_socket = accept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length)) == OFInvalidSocketHandle)
@throw [OFAcceptFailedException
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
# if defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1)
fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC);
# endif
|