54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
+
|
#import "macros.h"
#ifndef INVALID_SOCKET
# define INVALID_SOCKET -1
#endif
#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
# import "OFThread.h"
# import "OFMutex.h"
# import "OFDataArray.h"
static OFMutex *mutex = nil;
#endif
#ifdef _WIN32
# define close(sock) closesocket(sock)
|
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
-
-
-
+
-
-
-
-
+
-
-
+
-
-
|
OFTCPSocket *newSocket;
struct sockaddr_storage *addr;
socklen_t addrLen;
int newSock;
newSocket = [[[[self class] alloc] init] autorelease];
addrLen = sizeof(*addr);
@try {
addr = [newSocket allocMemoryWithSize: addrLen];
addr = [newSocket allocMemoryWithSize: addrLen];
} @catch (id e) {
[newSocket release];
@throw e;
}
if ((newSock = accept(sock, (struct sockaddr*)addr,
&addrLen)) == INVALID_SOCKET) {
&addrLen)) == INVALID_SOCKET)
[newSocket release];
@throw [OFAcceptFailedException exceptionWithClass: [self class]
socket: self];
}
newSocket->sock = newSock;
newSocket->sockAddr = addr;
newSocket->sockAddrLen = addrLen;
return newSocket;
}
|