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
|
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
/* {} needed to avoid warning with Clang 10 if next #if is false. */
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) {
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
}
#endif
#if defined(OF_WII) || defined(OF_NINTENDO_3DS)
if (of_socket_address_get_port(address) != 0) {
#endif
if (bind(_socket, &address->sockaddr.sockaddr,
address->length) != 0) {
int errNo = of_socket_errno();
closesocket(_socket);
_socket = INVALID_SOCKET;
host = of_socket_address_ip_string(address, &port);
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
#if defined(OF_WII) || defined(OF_NINTENDO_3DS)
} else {
for (;;) {
uint16_t rnd = 0;
int ret;
while (rnd < 1024)
rnd = (uint16_t)rand();
|
|
|
|
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
|
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
/* {} needed to avoid warning with Clang 10 if next #if is false. */
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) {
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
}
#endif
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
if (of_socket_address_get_port(address) != 0) {
#endif
if (bind(_socket, &address->sockaddr.sockaddr,
address->length) != 0) {
int errNo = of_socket_errno();
closesocket(_socket);
_socket = INVALID_SOCKET;
host = of_socket_address_ip_string(address, &port);
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
} else {
for (;;) {
uint16_t rnd = 0;
int ret;
while (rnd < 1024)
rnd = (uint16_t)rand();
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#endif
objc_autoreleasePoolPop(pool);
if ((port = of_socket_address_get_port(address)) > 0)
return port;
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
memset(address, 0, sizeof(*address));
address->length = (socklen_t)sizeof(address->sockaddr);
if (of_getsockname(_socket, &address->sockaddr.sockaddr,
&address->length) != 0) {
int errNo = of_socket_errno();
|
|
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#endif
objc_autoreleasePoolPop(pool);
if ((port = of_socket_address_get_port(address)) > 0)
return port;
#if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
memset(address, 0, sizeof(*address));
address->length = (socklen_t)sizeof(address->sockaddr);
if (of_getsockname(_socket, &address->sockaddr.sockaddr,
&address->length) != 0) {
int errNo = of_socket_errno();
|