Differences From Artifact [73d0c39dd0]:
- File
src/OFTCPSocket.m
— part of check-in
[8faa16f249]
at
2013-06-13 01:59:45
on branch trunk
— Try inet_addr() before gethostbyname().
gethostbyname() is not required to accept an IP address and does not do
so on the Wii. (user: js, size: 17988) [annotate] [blame] [check-ins using]
To Artifact [17c2cc5542]:
- File
src/OFTCPSocket.m
— part of check-in
[ca113e0145]
at
2013-06-13 02:03:13
on branch trunk
— Don't bind to port 0 on the Wii.
Instead, a decreasing variable is used now. This should be safe, as
nothing else should be binding ports while homebrew code is running. The
only problem that could arise is when code manually binds to very high
port numbers.This also solves the problem that getsockname() is not available on the
Wii, as we know the port now anyway.And while we're at it, this also adds struct sockaddr_storage. (user: js, size: 18148) [annotate] [blame] [check-ins using]
︙ | |||
88 89 90 91 92 93 94 | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | - + + + + + + + + + + | #ifdef __wii__ # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) # define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen) # define close(sock) net_close(sock) # define connect(sock, addr, addrlen) net_connect(sock, addr, addrlen) # define gethostbyname(name) net_gethostbyname(name) |
︙ | |||
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | + + + + + + + | union { struct sockaddr_storage storage; struct sockaddr_in in; #ifdef AF_INET6 struct sockaddr_in6 in6; #endif } addr; #ifndef __wii__ socklen_t addrLen; #endif if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithClass: [self class] socket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; #ifdef __wii__ if (port == 0) port = freePort--; #endif #ifdef HAVE_THREADSAFE_GETADDRINFO struct addrinfo hints, *res; char portCString[7]; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; |
︙ | |||
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | + - + + | port: port]; } #endif if (port > 0) return port; #ifndef __wii__ addrLen = sizeof(addr.storage); if (getsockname(_socket, (struct sockaddr*)&addr, &addrLen)) { close(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } if (addr.storage.ss_family == AF_INET) return OF_BSWAP16_IF_LE(addr.in.sin_port); |
︙ |