Comment: | Remove resolver.m
Instead, OFDNSResolver is used for everything now. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6e9ee122eb2336a5e6f730393a100df6 |
User & Date: | js on 2018-10-07 02:06:46 |
Other Links: | manifest | tags |
2018-10-07
| ||
02:39 | OFDNSResolver: Look at static hosts to get address check-in: 4d335e89d6 user: js tags: trunk | |
02:06 | Remove resolver.m check-in: 6e9ee122eb user: js tags: trunk | |
2018-10-06
| ||
20:21 | OFDNSResolver: Add sync resolve socket addresses check-in: 22700e6082 user: js tags: trunk | |
Modified configure.ac from [0289c3600c] to [ca5e9322d2].
︙ | ︙ | |||
1304 1305 1306 1307 1308 1309 1310 | [Whether we have select() or similar]) AC_SUBST(OFKERNELEVENTOBSERVER_SELECT_M, "OFKernelEventObserver_select.m") ]) ;; esac | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | [Whether we have select() or similar]) AC_SUBST(OFKERNELEVENTOBSERVER_SELECT_M, "OFKernelEventObserver_select.m") ]) ;; esac AS_IF([test x"$enable_threads" != x"no"], [ AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m") ]) AC_SUBST(OFDNS, "ofdns") AS_IF([test x"$enable_files" != x"no"], [ AC_SUBST(OFHTTP, "ofhttp") |
︙ | ︙ |
Modified src/Makefile from [d620634847] to [25efe5c01f].
︙ | ︙ | |||
130 131 132 133 134 135 136 | OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ | < | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ socket.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFRecursiveMutex.m \ OFThreadPool.m \ threading.m SRCS_WINDOWS = OFStdIOStream_Win32Console.m \ |
︙ | ︙ |
Modified src/OFDNSResolver.m from [8f4fd230d2] to [f094c42133].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFFile.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFTimer.h" #import "OFUDPSocket.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" | > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFFile.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFTimer.h" #import "OFUDPSocket.h" #import "OFUDPSocket+Private.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" |
︙ | ︙ | |||
1780 1781 1782 1783 1784 1785 1786 1787 | objectAtIndex: query->_nameServersIndex]; query->_usedNameServer = of_socket_address_parse_ip(nameServer, 53); switch (query->_usedNameServer.family) { #ifdef OF_HAVE_IPV6 case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (_IPv6Socket == nil) { _IPv6Socket = [[OFUDPSocket alloc] init]; | > > > | < > > > | < | 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 | objectAtIndex: query->_nameServersIndex]; query->_usedNameServer = of_socket_address_parse_ip(nameServer, 53); switch (query->_usedNameServer.family) { #ifdef OF_HAVE_IPV6 case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (_IPv6Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address]; [_IPv6Socket setBlocking: false]; } sock = _IPv6Socket; break; #endif case OF_SOCKET_ADDRESS_FAMILY_IPV4: if (_IPv4Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"0.0.0.0", 0); _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address]; [_IPv4Socket setBlocking: false]; } sock = _IPv4Socket; break; default: @throw [OFInvalidArgumentException exception]; |
︙ | ︙ | |||
2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 | runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)userContext { void *pool = objc_autoreleasePoolPush(); OFDNSResolver_AsyncResolveSocketAddressesContext *context; context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc] initWithHost: host target: target selector: selector context: userContext] autorelease]; | > > > > > > > > > > > > > > > > > > > > > > | 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 | runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)userContext { void *pool = objc_autoreleasePoolPush(); OFDNSResolver_AsyncResolveSocketAddressesContext *context; @try { of_socket_address_t address = of_socket_address_parse_ip(host, 0); OFData *addresses; void (*method)(id, SEL, OFDNSResolver *, OFString *, OFData *, id, id); if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY && address.family != addressFamily) @throw [OFInvalidArgumentException exception]; addresses = [OFData dataWithItems: &address itemSize: sizeof(address) count: 1]; method = (void (*)(id, SEL, OFDNSResolver *, OFString *, OFData *, id, id))[target methodForSelector: selector]; method(target, selector, self, host, addresses, userContext, nil); } @catch (OFInvalidFormatException *e) { } context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc] initWithHost: host target: target selector: selector context: userContext] autorelease]; |
︙ | ︙ |
Modified src/OFRunLoop.m from [54ecb2a574] to [b99d9d1539].
︙ | ︙ | |||
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | beforeDate: deadline]; } - (void)runMode: (of_run_loop_mode_t)mode beforeDate: (OFDate *)deadline { void *pool = objc_autoreleasePoolPush(); OFRunLoop_State *state = [self of_stateForMode: mode create: false]; if (state == nil) return; _currentMode = mode; | > | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | beforeDate: deadline]; } - (void)runMode: (of_run_loop_mode_t)mode beforeDate: (OFDate *)deadline { void *pool = objc_autoreleasePoolPush(); of_run_loop_mode_t previousMode = _currentMode; OFRunLoop_State *state = [self of_stateForMode: mode create: false]; if (state == nil) return; _currentMode = mode; |
︙ | ︙ | |||
1247 1248 1249 1250 1251 1252 1253 | #else [OFThread sleepForTimeInterval: 86400]; #endif } objc_autoreleasePoolPop(pool); } @finally { | | | 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 | #else [OFThread sleepForTimeInterval: 86400]; #endif } objc_autoreleasePoolPop(pool); } @finally { _currentMode = previousMode; } } - (void)stop { OFRunLoop_State *state = [self of_stateForMode: of_run_loop_mode_default create: false]; |
︙ | ︙ |
Modified src/OFTCPSocket.m from [2642e89679] to [0378e7d3f9].
︙ | ︙ | |||
53 54 55 56 57 58 59 | #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" #import "socket.h" #import "socket_helpers.h" | < | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" #import "socket.h" #import "socket_helpers.h" Class of_tls_socket_class = Nil; static of_run_loop_mode_t connectRunLoopMode = @"of_tcp_socket_connect_mode"; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; |
︙ | ︙ | |||
862 863 864 865 866 867 868 | objc_autoreleasePoolPop(pool); } #endif - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { | < > | > > > | < | | | > | < | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < | < < | < < < < < < < < < < < < | < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < > > | > > > > > > > > > | | 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 | objc_autoreleasePoolPop(pool); } #endif - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { const int one = 1; void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; of_socket_address_t address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; socketAddresses = [[OFThread DNSResolver] resolveSocketAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY]; address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0]; of_socket_address_set_port(&address, port); if ((_socket = socket(address.sockaddr.sockaddr.sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; _blocking = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, (socklen_t)sizeof(one)); #if defined(OF_WII) || defined(OF_NINTENDO_3DS) if (port != 0) { #endif if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { int errNo = of_socket_errno(); closesocket(_socket); _socket = INVALID_SOCKET; @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(); of_socket_address_set_port(&address, rnd); if ((ret = bind(_socket, &address.sockaddr.sockaddr, address.length)) == 0) { port = rnd; break; } if (of_socket_errno() != EADDRINUSE) { int errNo = of_socket_errno(); closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } } #endif objc_autoreleasePoolPop(pool); if (port > 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(); closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } if (address.sockaddr.sockaddr.sa_family == AF_INET) return OF_BSWAP16_IF_LE(address.sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 else if (address.sockaddr.sockaddr.sa_family == AF_INET6) return OF_BSWAP16_IF_LE(address.sockaddr.in6.sin6_port); # endif else { closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #endif closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EADDRNOTAVAIL]; } - (void)listen { [self listenWithBacklog: SOMAXCONN]; } |
︙ | ︙ |
Added src/OFUDPSocket+Private.h version [9f1517e8f1].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFUDPSocket.h" OF_ASSUME_NONNULL_BEGIN @interface OFUDPSocket () - (uint16_t)of_bindToAddress: (of_socket_address_t *)address; @end OF_ASSUME_NONNULL_END |
Modified src/OFUDPSocket.h from [29dec683be] to [201326e03a].
︙ | ︙ | |||
24 25 26 27 28 29 30 | OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFUDPSocket; #ifdef OF_HAVE_BLOCKS | < < < < < < < < < < < < < | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFUDPSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when a packet has been received. * * @param socket The UDP socket which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param sender The address of the sender of the packet |
︙ | ︙ | |||
80 81 82 83 84 85 86 | #endif /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * * @brief A class which provides methods to create and use UDP sockets. * | | | | | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #endif /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * * @brief A class which provides methods to create and use UDP sockets. * * Addresses are of type @ref of_socket_address_t. You can use the current * thread's @ref OFDNSResolver to create an address for a host / port pair and * @ref of_socket_address_ip_string to get the IP string / port pair for an * address. If you want to compare two addresses, you can use @ref * of_socket_address_equal and you can use @ref of_socket_address_hash 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 * was called to create one "instance" for every thread! |
︙ | ︙ | |||
118 119 120 121 122 123 124 | /*! * @brief Returns a new, autoreleased OFUDPSocket. * * @return A new, autoreleased OFUDPSocket */ + (instancetype)socket; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /*! * @brief Returns a new, autoreleased OFUDPSocket. * * @return A new, autoreleased OFUDPSocket */ + (instancetype)socket; /*! * @brief Binds the socket to the specified host and port. * * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. |
︙ | ︙ |
Modified src/OFUDPSocket.m from [e0fb2ac475] to [073268c5ca].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #include <string.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFUDPSocket.h" | | > | < | | > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #include <string.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFUDPSocket.h" #import "OFUDPSocket+Private.h" #import "OFDNSResolver.h" #import "OFData.h" #import "OFRunLoop+Private.h" #import "OFRunLoop.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" #import "OFBindFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #import "socket.h" #import "socket_helpers.h" @implementation OFUDPSocket + (void)initialize { if (self != [OFUDPSocket class]) return; if (!of_socket_init()) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)socket { return [[[self alloc] init] autorelease]; } - (instancetype)init { self = [super init]; _socket = INVALID_SOCKET; _blocking = true; |
︙ | ︙ | |||
324 325 326 327 328 329 330 | _blocking = enable; #else OF_UNRECOGNIZED_SELECTOR #endif } | < | < < < < | | | | | < | > | | | | | > | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < | < < | < < < < < < < < < < < < | < < < | | < < | | < | > > > > | | | | < < < < < < < < < < < < | < < < < < < < < < < < < | | | | > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | _blocking = enable; #else OF_UNRECOGNIZED_SELECTOR #endif } - (uint16_t)of_bindToAddress: (of_socket_address_t *)address { void *pool = objc_autoreleasePoolPush(); OFString *host; uint16_t port; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if ((_socket = socket(address->sockaddr.sockaddr.sa_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) { host = of_socket_address_ip_string(address, &port); @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; } _blocking = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) 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 (port != 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(); of_socket_address_set_port(address, rnd); if ((ret = bind(_socket, &address->sockaddr.sockaddr, address->length)) == 0) { port = rnd; break; } if (of_socket_errno() != EADDRINUSE) { 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]; } } } #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(); closesocket(_socket); _socket = INVALID_SOCKET; host = of_socket_address_ip_string(address, &port); @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } if (address->sockaddr.sockaddr.sa_family == AF_INET) return OF_BSWAP16_IF_LE(address->sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 else if (address->sockaddr.sockaddr.sa_family == AF_INET6) return OF_BSWAP16_IF_LE(address->sockaddr.in6.sin6_port); # endif else { closesocket(_socket); _socket = INVALID_SOCKET; host = of_socket_address_ip_string(address, &port); @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #endif closesocket(_socket); _socket = INVALID_SOCKET; host = of_socket_address_ip_string(address, &port); @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EADDRNOTAVAIL]; } - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; of_socket_address_t address; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; socketAddresses = [[OFThread DNSResolver] resolveSocketAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY]; address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0]; of_socket_address_set_port(&address, port); port = [self of_bindToAddress: &address]; objc_autoreleasePoolPop(pool); return port; } - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length sender: (of_socket_address_t *)sender { ssize_t ret; |
︙ | ︙ |
Modified src/ObjFW.h from [3fac06979c] to [ee89e1ae2e].
︙ | ︙ | |||
239 240 241 242 243 244 245 | #import "base64.h" #import "crc16.h" #import "crc32.h" #import "huffman_tree.h" #import "instance.h" #import "of_asprintf.h" #import "of_strptime.h" | < < < | 239 240 241 242 243 244 245 246 247 248 | #import "base64.h" #import "crc16.h" #import "crc32.h" #import "huffman_tree.h" #import "instance.h" #import "of_asprintf.h" #import "of_strptime.h" #import "pbkdf2.h" #import "scrypt.h" #import "unicode.h" |
Deleted src/resolver.h version [8e4bcb1595].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/resolver.m version [aa220e27b3].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/socket.h from [2431bf7b16] to [949bb8ad8d].
︙ | ︙ | |||
203 204 205 206 207 208 209 210 211 212 213 214 | * the address family used. * * @param address The address on which to set the port * @param port The port to set on the address */ extern void of_socket_address_set_port(of_socket_address_t *_Nonnull address, uint16_t port); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | > > > > > > > > > > | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | * the address family used. * * @param address The address on which to set the port * @param port The port to set on the address */ extern void of_socket_address_set_port(of_socket_address_t *_Nonnull address, uint16_t port); /*! * @brief Returns the port of the specified of_socket_address_t, independent of * the address family used. * * @param address The address on which to get the port * @return The port of the address */ extern uint16_t of_socket_address_get_port( const of_socket_address_t *_Nonnull address); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/socket.m from [72b93f58cf] to [00380c738c].
︙ | ︙ | |||
604 605 606 607 608 609 610 | case OF_SOCKET_ADDRESS_FAMILY_IPV6: address->sockaddr.in6.sin6_port = OF_BSWAP16_IF_LE(port); break; default: @throw [OFInvalidArgumentException exception]; } } | > > > > > > > > > > > > > | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | case OF_SOCKET_ADDRESS_FAMILY_IPV6: address->sockaddr.in6.sin6_port = OF_BSWAP16_IF_LE(port); break; default: @throw [OFInvalidArgumentException exception]; } } uint16_t of_socket_address_get_port(const of_socket_address_t *address) { switch (address->family) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: return OF_BSWAP16_IF_LE(address->sockaddr.in.sin_port); case OF_SOCKET_ADDRESS_FAMILY_IPV6: return OF_BSWAP16_IF_LE(address->sockaddr.in6.sin6_port); default: @throw [OFInvalidArgumentException exception]; } } |
Modified src/socket_helpers.h from [9196eb16cc] to [0b9f3f23ab].
︙ | ︙ | |||
28 29 30 31 32 33 34 | #include "socket.h" #ifndef INVALID_SOCKET # define INVALID_SOCKET -1 #endif | < < < < < < < < < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include "socket.h" #ifndef INVALID_SOCKET # define INVALID_SOCKET -1 #endif #ifndef INADDR_NONE # define INADDR_NONE ((in_addr_t)-1) #endif #ifndef SOMAXCONN /* * Use 16 as everything > 17 fails on Nintendo 3DS and 16 is a less arbitrary |
︙ | ︙ | |||
73 74 75 76 77 78 79 | #ifdef OF_WII # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) # define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen) # define closesocket(sock) net_close(sock) # define connect(sock, addr, addrlen) \ net_connect(sock, (struct sockaddr *)addr, addrlen) # define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags) | < | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #ifdef OF_WII # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) # define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen) # define closesocket(sock) net_close(sock) # define connect(sock, addr, addrlen) \ net_connect(sock, (struct sockaddr *)addr, addrlen) # define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags) # define getsockopt(sock, level, name, value, len) \ net_getsockopt(sock, level, name, value, len) # define h_errno 0 # define hstrerror(err) "unknown (no hstrerror)" # define listen(sock, backlog) net_listen(sock, backlog) # define poll(fds, nfds, timeout) net_poll(fds, nfds, timeout) # define recv(sock, buf, len, flags) net_recv(sock, buf, len, flags) |
︙ | ︙ |
Modified tests/OFUDPSocketTests.m from [1bbed581ea] to [b4dbd2c54c].
︙ | ︙ | |||
39 40 41 42 43 44 45 | TEST(@"+[socket]", (sock = [OFUDPSocket socket])) TEST(@"-[bindToHost:port:]", (port1 = [sock bindToHost: @"127.0.0.1" port: 0])) | < | < < | < < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | TEST(@"+[socket]", (sock = [OFUDPSocket socket])) TEST(@"-[bindToHost:port:]", (port1 = [sock bindToHost: @"127.0.0.1" port: 0])) addr1 = of_socket_address_parse_ip(@"127.0.0.1", port1); TEST(@"-[sendBuffer:length:receiver:]", R([sock sendBuffer: "Hello" length: 6 receiver: &addr1])) TEST(@"-[receiveIntoBuffer:length:sender:]", [sock receiveIntoBuffer: buf length: 6 sender: &addr2] == 6 && !memcmp(buf, "Hello", 6) && (host = of_socket_address_ip_string(&addr2, &port2)) && [host isEqual: @"127.0.0.1"] && port2 == port1) addr3 = of_socket_address_parse_ip(@"127.0.0.1", port1 + 1); /* * TODO: Move those tests elsewhere as soon as the DNS resolving part * is no longer in OFUDPSocket. */ TEST(@"of_socket_address_equal()", of_socket_address_equal(&addr1, &addr2) && |
︙ | ︙ |