Overview
Comment: | Minor fixes for last commit |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | new-naming-convention |
Files: | files | file ages | folders |
SHA3-256: |
c45a1085852f19c7a156f5988937526b |
User & Date: | js on 2021-04-17 14:05:38 |
Other Links: | branch diff | manifest | tags |
Context
2021-04-17
| ||
14:13 | Always prefix functions with the type check-in: eb0cfa6ff9 user: js tags: new-naming-convention | |
14:05 | Minor fixes for last commit check-in: c45a108585 user: js tags: new-naming-convention | |
13:58 | of_socket_address_t -> OFSocketAddress check-in: e3c5bb70dd user: js tags: new-naming-convention | |
Changes
Modified src/OFUDPSocket.h from [758612bc48] to [7fc9c66432].
︙ | ︙ | |||
33 34 35 36 37 38 39 | * @brief A class which provides methods to create and use UDP sockets. * * Addresses are of type @ref OFSocketAddress. You can use the current thread's * @ref OFDNSResolver to create an address for a host / port pair, * @ref OFSocketAddressString to get the IP address string for an address and * @ref OFSocketAddressPort to get the port for an address. If you want to * compare two addresses, you can use | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * @brief A class which provides methods to create and use UDP sockets. * * Addresses are of type @ref OFSocketAddress. You can use the current thread's * @ref OFDNSResolver to create an address for a host / port pair, * @ref OFSocketAddressString to get the IP address string for an address and * @ref OFSocketAddressPort to get the port for an address. If you want to * compare two addresses, you can use * @ref OFSocketAddressEqual and you can use @ref OFSocketAddressHash to get a * hash to use in e.g. @ref OFMapTable. * * @warning Even though the OFCopying protocol is implemented, it does *not* * return an independent copy of the socket, but instead retains it. * This is so that the socket can be used as a key for a dictionary, * so context can be associated with a socket. Using a socket in more * than one thread at the same time is not thread-safe, even if copy |
︙ | ︙ |
Modified src/socket.m from [b7f2de7d48] to [35ea54e031].
︙ | ︙ | |||
676 677 678 679 680 681 682 | OF_HASH_FINALIZE(hash); return hash; } static OFString * | | | | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | OF_HASH_FINALIZE(hash); return hash; } static OFString * IPv4String(const OFSocketAddress *address) { const struct sockaddr_in *addrIn = &address->sockaddr.in; uint32_t addr = OF_BSWAP32_IF_LE(addrIn->sin_addr.s_addr); OFString *string; string = [OFString stringWithFormat: @"%u.%u.%u.%u", (addr & 0xFF000000) >> 24, (addr & 0x00FF0000) >> 16, (addr & 0x0000FF00) >> 8, addr & 0x000000FF]; return string; } static OFString * IPv6String(const OFSocketAddress *address) { OFMutableString *string = [OFMutableString string]; const struct sockaddr_in6 *addrIn6 = &address->sockaddr.in6; int_fast8_t zerosStart = -1, maxZerosStart = -1; uint_fast8_t zerosCount = 0, maxZerosCount = 0; bool first = true; |
︙ | ︙ | |||
761 762 763 764 765 766 767 | } OFString * OFSocketAddressString(const OFSocketAddress *address) { switch (address->family) { case OFSocketAddressFamilyIPv4: | | | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | } OFString * OFSocketAddressString(const OFSocketAddress *address) { switch (address->family) { case OFSocketAddressFamilyIPv4: return IPv4String(address); case OFSocketAddressFamilyIPv6: return IPv6String(address); default: @throw [OFInvalidArgumentException exception]; } } void OFSocketAddressSetPort(OFSocketAddress *address, uint16_t port) |
︙ | ︙ |
Modified tests/OFIPXSocketTests.m from [fbc341af78] to [2def7aa281].
︙ | ︙ | |||
59 60 61 62 63 64 65 | TEST(@"-[sendBuffer:length:receiver:]", R([sock sendBuffer: "Hello" length: 5 receiver: &address1])) TEST(@"-[receiveIntoBuffer:length:sender:]", [sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 && memcmp(buffer, "Hello", 5) == 0 && OFSocketAddressEqual(&address1, &address2) && | | | 59 60 61 62 63 64 65 66 67 68 69 70 | TEST(@"-[sendBuffer:length:receiver:]", R([sock sendBuffer: "Hello" length: 5 receiver: &address1])) TEST(@"-[receiveIntoBuffer:length:sender:]", [sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 && memcmp(buffer, "Hello", 5) == 0 && OFSocketAddressEqual(&address1, &address2) && OFSocketAddressHash(&address1) == OFSocketAddressHash(&address2)) objc_autoreleasePoolPop(pool); } @end |