Differences From Artifact [76989391ef]:
- File src/OFTCPSocket.m — part of check-in [d0eab356ce] at 2015-09-06 15:48:17 on branch trunk — Fix compilation for Wii (user: js, size: 14127) [annotate] [blame] [check-ins using] [more...]
To Artifact [a3e1049524]:
- File
src/OFTCPSocket.m
— part of check-in
[ed4549ddd3]
at
2015-10-17 10:59:15
on branch trunk
— Add a port registry for the Wii
This is necessary as the Wii does not allow picking a random free port,
and thus we need to track which ports are used. (user: js, size: 14655) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
59 60 61 62 63 64 65 | } Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; | < < < < | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; #ifdef OF_HAVE_THREADS @interface OFTCPSocket_ConnectThread: OFThread { OFThread *_sourceThread; OFTCPSocket *_socket; OFString *_host; uint16_t _port; |
︙ | ︙ | |||
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_SOCKS5Host release]; [super dealloc]; } | > > > > > > > > > > > > | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | } @catch (id e) { [self release]; @throw e; } return self; } - (void)close { [super close]; #ifdef __wii__ if (_port > 0) { of_socket_port_free(_port, SOCK_STREAM); _port = 0; } #endif } - (void)dealloc { [_SOCKS5Host release]; [super dealloc]; } |
︙ | ︙ | |||
397 398 399 400 401 402 403 | if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; #ifdef __wii__ if (port == 0) | > > > | > > > | > > > > > > > | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; #ifdef __wii__ if (port == 0) port = of_socket_port_find(SOCK_STREAM); else if (!of_socket_port_register(port, SOCK_STREAM)) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EADDRINUSE]; #endif @try { results = of_resolve_host(host, port, SOCK_STREAM); } @catch (id e) { #ifdef __wii__ of_socket_port_free(port, SOCK_STREAM); #endif @throw e; } @try { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if ((_socket = socket(results[0]->family, results[0]->type | SOCK_CLOEXEC, |
︙ | ︙ | |||
435 436 437 438 439 440 441 442 443 444 445 | _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } @finally { of_resolver_free(results); } | > > > > > | > > > > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } @catch (id e) { #ifdef __wii__ of_socket_port_free(port, SOCK_STREAM); #endif @throw e; } @finally { of_resolver_free(results); } if (port > 0) { #ifdef __wii__ _port = port; #endif return port; } #ifndef __wii__ addrLen = (socklen_t)sizeof(addr.storage); if (of_getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen) != 0) { int errNo = of_socket_errno(); |
︙ | ︙ |