53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
if ((_socket = socket(address.sockaddr.sockaddr.sa_family,
SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == INVALID_SOCKET)
@throw [OFBindFailedException
exceptionWithPort: port
packetType: packetType
socket: self
errNo: of_socket_errno()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) {
int errNo = of_socket_errno();
closesocket(_socket);
_socket = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (of_getsockname(_socket, &address.sockaddr.sockaddr,
&address.length) != 0) {
int errNo = of_socket_errno();
closesocket(_socket);
_socket = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
|
|
|
|
|
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
if ((_socket = socket(address.sockaddr.sockaddr.sa_family,
SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == INVALID_SOCKET)
@throw [OFBindFailedException
exceptionWithPort: port
packetType: packetType
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, &address.sockaddr.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
|