Comment: | Split OFBindSocketFailedException into subclasses |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
72db6b3c6f53d9de26d5eb729223b06d |
User & Date: | js on 2022-10-22 16:00:37 |
Other Links: | manifest | tags |
2022-10-22
| ||
16:41 | OF[IS]PX(Stream)Socket: Bind with network & node check-in: b29f11ed25 user: js tags: trunk | |
16:00 | Split OFBindSocketFailedException into subclasses check-in: 72db6b3c6f user: js tags: trunk | |
15:07 | Rename OFBind{ -> Socket}FailedException check-in: 35b565d369 user: js tags: trunk | |
Modified src/OFIPXSocket.h from [3f2d188d81] to [ef99df60be].
︙ | ︙ | |||
67 68 69 70 71 72 73 | * @brief Bind the socket to the specified network, node and port with the * specified packet type. * * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @param packetType The packet type to use on the socket * @return The address on which this socket can be reached | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | * @brief Bind the socket to the specified network, node and port with the * specified packet type. * * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @param packetType The packet type to use on the socket * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already bound */ - (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType; @end OF_ASSUME_NONNULL_END |
Modified src/OFIPXSocket.m from [7c065986f3] to [0a75c9cc64].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #endif #import "OFIPXSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #endif #import "OFIPXSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" #import "OFBindIPXSocketFailedException.h" @implementation OFIPXSocket @dynamic delegate; - (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType { const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; |
︙ | ︙ | |||
49 50 51 52 53 54 55 | protocol = NSPROTO_IPX + packetType; #else _packetType = address.sockaddr.ipx.sipx_type = packetType; #endif if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle) | | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | protocol = NSPROTO_IPX + packetType; #else _packetType = address.sockaddr.ipx.sipx_type = packetType; #endif if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: packetType socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: packetType socket: self errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: packetType socket: self errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: packetType socket: self errNo: EAFNOSUPPORT]; } return address; |
︙ | ︙ |
Modified src/OFSPXSocket.h from [7301372af3] to [dd73febed0].
︙ | ︙ | |||
156 157 158 159 160 161 162 | /** * @brief Bind the socket to the specified network, node and port. * * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @return The address on which this socket can be reached | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /** * @brief Bind the socket to the specified network, node and port. * * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (OFSocketAddress)bindToPort: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFSPXSocket.m from [3f35e5cfcb] to [58b6b2aee3].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFSPXSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #import "OFSPXSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" #import "OFBindIPXSocketFailedException.h" #import "OFConnectionFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif |
︙ | ︙ | |||
325 326 327 328 329 330 331 | @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) | | | | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: EAFNOSUPPORT]; } return address; } @end |
Modified src/OFSPXStreamSocket.m from [f1965656ad] to [2dd457649f].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFSPXStreamSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #import "OFSPXStreamSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" #import "OFBindIPXSocketFailedException.h" #import "OFConnectionFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif |
︙ | ︙ | |||
326 327 328 329 330 331 332 | if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) | | | | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: EAFNOSUPPORT]; } return address; } @end |
Modified src/OFTCPSocket.h from [5b7d6c5295] to [171e9901f1].
︙ | ︙ | |||
210 211 212 213 214 215 216 | * @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. * @return The port the socket was bound to | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | * @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. * @return The port the socket was bound to * @throw OFBindIPSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFTCPSocket.m from [f494d07225] to [e6378dfef4].
︙ | ︙ | |||
40 41 42 43 44 45 46 | #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFTCPSocketSOCKS5Connector.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFTCPSocketSOCKS5Connector.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" #import "OFBindIPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFSetOptionFailedException.h" static const OFRunLoopMode connectRunLoopMode = @"OFTCPSocketConnectRunLoopMode"; |
︙ | ︙ | |||
312 313 314 315 316 317 318 | address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; OFSocketAddressSetPort(&address, port); if ((_socket = socket( ((struct sockaddr *)&address.sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; OFSocketAddressSetPort(&address, port); if ((_socket = socket( ((struct sockaddr *)&address.sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: OFSocketErrNo()]; _canBlock = true; |
︙ | ︙ | |||
338 339 340 341 342 343 344 | if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } #if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) } else { |
︙ | ︙ | |||
368 369 370 371 372 373 374 | if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } } |
︙ | ︙ | |||
394 395 396 397 398 399 400 | if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | | | | | | | | | 394 395 396 397 398 399 400 401 402 403 404 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 436 437 | if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } switch (((struct sockaddr *)&address.sockaddr)->sa_family) { case AF_INET: return OFFromBigEndian16(address.sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 case AF_INET6: return OFFromBigEndian16(address.sockaddr.in6.sin6_port); # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #else closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: EADDRNOTAVAIL]; #endif } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) - (void)setSendsKeepAlives: (bool)sendsKeepAlives { int v = sendsKeepAlives; |
︙ | ︙ |
Modified src/OFUDPSocket.h from [9064e55448] to [c4641067b3].
︙ | ︙ | |||
68 69 70 71 72 73 74 | * @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. * @return The port the socket was bound to | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * @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. * @return The port the socket was bound to * @throw OFBindIPSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already bound */ - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFUDPSocket.m from [080326bc21] to [fd8f9dff29].
︙ | ︙ | |||
31 32 33 34 35 36 37 | #import "OFDNSResolver.h" #import "OFData.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" | | | | 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 | #import "OFDNSResolver.h" #import "OFData.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" #import "OFBindIPSocketFailedException.h" @implementation OFUDPSocket @dynamic delegate; - (uint16_t)of_bindToAddress: (OFSocketAddress *)address extraType: (int)extraType OF_DIRECT { void *pool = objc_autoreleasePoolPush(); uint16_t port; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: OFSocketErrNo()]; _canBlock = true; |
︙ | ︙ | |||
73 74 75 76 77 78 79 | if (bind(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | if (bind(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: errNo]; } #if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) } else { |
︙ | ︙ | |||
103 104 105 106 107 108 109 | int errNo = OFSocketErrNo(); OFString *host = OFSocketAddressString(address); port = OFSocketAddressPort(address); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | int errNo = OFSocketErrNo(); OFString *host = OFSocketAddressString(address); port = OFSocketAddressPort(address); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } } |
︙ | ︙ | |||
129 130 131 132 133 134 135 | if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr, &address->length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; | | | | | 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 | if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr, &address->length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: errNo]; } switch (((struct sockaddr *)&address->sockaddr)->sa_family) { case AF_INET: return OFFromBigEndian16(address->sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 case AF_INET6: return OFFromBigEndian16(address->sockaddr.in6.sin6_port); # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: EAFNOSUPPORT]; } #else closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: EADDRNOTAVAIL]; #endif } |
︙ | ︙ |
Modified src/OFUNIXDatagramSocket.h from [a2c9620021] to [0a3ec7f2ad].
︙ | ︙ | |||
61 62 63 64 65 66 67 | id <OFUNIXDatagramSocketDelegate> delegate; /** * @brief Bind the socket to the specified path. * * @param path The path to bind to * @return The address on which this socket can be reached | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | id <OFUNIXDatagramSocketDelegate> delegate; /** * @brief Bind the socket to the specified path. * * @param path The path to bind to * @return The address on which this socket can be reached * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already bound */ - (OFSocketAddress)bindToPath: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified src/OFUNIXDatagramSocket.m from [45b8d937e9] to [7203060d9a].
︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "OFUNIXDatagramSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" | | | > | | | | 21 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 73 74 | #import "OFUNIXDatagramSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" #import "OFBindUNIXSocketFailedException.h" @implementation OFUNIXDatagramSocket @dynamic delegate; - (OFSocketAddress)bindToPath: (OFString *)path { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: errNo]; } return address; } @end |
Modified src/OFUNIXStreamSocket.h from [b908fbf9aa] to [dd9639b932].
︙ | ︙ | |||
59 60 61 62 63 64 65 | */ - (void)connectToPath: (OFString *)path; /** * @brief Binds the socket to the specified host and port. * * @param path The path to bind to | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | */ - (void)connectToPath: (OFString *)path; /** * @brief Binds the socket to the specified host and port. * * @param path The path to bind to * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)bindToPath: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified src/OFUNIXStreamSocket.m from [af5f7ae84f] to [0dc4ba7cbd].
︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "OFUNIXStreamSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #import "OFUNIXStreamSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" #import "OFBindUNIXSocketFailedException.h" #import "OFConnectionFailedException.h" @implementation OFUNIXStreamSocket @dynamic delegate; - (void)connectToPath: (OFString *)path { |
︙ | ︙ | |||
80 81 82 83 84 85 86 | if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) | | > | | | | 80 81 82 83 84 85 86 87 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 | if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = 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 (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: errNo]; } } @end |
Modified src/ObjFW.h from [8b8202fcd3] to [700aa88375].
︙ | ︙ | |||
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | #import "OFAllocFailedException.h" #import "OFException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptFailedException.h" # import "OFAlreadyConnectedException.h" # import "OFBindSocketFailedException.h" #endif #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" #ifdef OF_HAVE_THREADS # import "OFConditionBroadcastFailedException.h" # import "OFConditionSignalFailedException.h" # import "OFConditionStillWaitingException.h" | > > > > > > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | #import "OFAllocFailedException.h" #import "OFException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptFailedException.h" # import "OFAlreadyConnectedException.h" # import "OFBindSocketFailedException.h" # import "OFBindIPSocketFailedException.h" # ifdef OF_HAVE_UNIX_SOCKETS # import "OFBindUNIXSocketFailedException.h" # endif # ifdef OF_HAVE_IPX # import "OFBindIPXSocketFailedException.h" # endif #endif #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" #ifdef OF_HAVE_THREADS # import "OFConditionBroadcastFailedException.h" # import "OFConditionSignalFailedException.h" # import "OFConditionStillWaitingException.h" |
︙ | ︙ |
Modified src/exceptions/Makefile from [d91b9a06b1] to [a3cc1fb55a].
︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \ OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAlreadyConnectedException.m \ OFBindSocketFailedException.m \ OFConnectionFailedException.m \ OFDNSQueryFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ OFObserveKernelEventsFailedException.m \ OFResolveHostFailedException.m \ | > | > > > > | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \ OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAlreadyConnectedException.m \ OFBindSocketFailedException.m \ OFBindIPSocketFailedException.m \ OFConnectionFailedException.m \ OFDNSQueryFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ OFObserveKernelEventsFailedException.m \ OFResolveHostFailedException.m \ OFTLSHandshakeFailedException.m \ ${USE_SRCS_IPX} \ ${USE_SRCS_UNIX_SOCKETS} SRCS_IPX = OFBindIPXSocketFailedException.m SRCS_UNIX_SOCKETS = OFBindUNIXSocketFailedException.m SRCS_THREADS = OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ OFConditionStillWaitingException.m \ OFConditionWaitFailedException.m \ OFThreadJoinFailedException.m \ OFThreadStartFailedException.m \ OFThreadStillRunningException.m |
︙ | ︙ |
Added src/exceptions/OFBindIPSocketFailedException.h version [5e1e83771b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 73 74 75 76 77 78 79 80 81 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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 "OFBindSocketFailedException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif OF_ASSUME_NONNULL_BEGIN /** * @class OFBindIPSocketFailedException \ * OFBindIPSocketFailedException.h ObjFW/OFBindIPSocketFailedException.h * * @brief An exception indicating that binding an IP socket failed. */ OF_SUBCLASSING_RESTRICTED @interface OFBindIPSocketFailedException: OFBindSocketFailedException { OFString *_Nullable _host; uint16_t _port; } /** * @brief The host on which binding failed. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *host; /** * @brief The port on which binding failed. */ @property (readonly, nonatomic) uint16_t port; /** * @brief Creates a new, autoreleased bind IP socket failed exception. * * @param host The host on which binding failed * @param port The port on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind IP socket failed exception */ + (instancetype)exceptionWithHost: (OFString *)host port: (uint16_t)port socket: (id)socket errNo: (int)errNo; + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind IP socket failed exception. * * @param host The host on which binding failed * @param port The port on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return An initialized bind IP socket failed exception */ - (instancetype)initWithHost: (OFString *)host port: (uint16_t)port socket: (id)socket errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/exceptions/OFBindIPSocketFailedException.m version [f9eddfdc09].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 73 74 75 76 77 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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. */ #include "config.h" #import "OFBindIPSocketFailedException.h" #import "OFString.h" @implementation OFBindIPSocketFailedException @synthesize host = _host, port = _port; + (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithHost: (OFString *)host port: (uint16_t)port socket: (id)sock errNo: (int)errNo { return [[[self alloc] initWithHost: host port: port socket: sock errNo: errNo] autorelease]; } - (instancetype)initWithSocket: (id)sock errNo: (int)errNo { OF_INVALID_INIT_METHOD } - (instancetype)initWithHost: (OFString *)host port: (uint16_t)port socket: (id)sock errNo: (int)errNo { self = [super initWithSocket: sock errNo: errNo]; @try { _host = [host copy]; _port = port; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_host release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Binding to port %" @PRIu16 @" on host %@ failed in socket of " @"type %@: %@", _port, _host, [_socket class], OFStrError(_errNo)]; } @end |
Added src/exceptions/OFBindIPXSocketFailedException.h version [27c4435d00].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 73 74 75 76 77 78 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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 "OFBindSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFBindIPXSocketFailedException \ * OFBindIPXSocketFailedException.h \ * ObjFW/OFBindIPXSocketFailedException.h * * @brief An exception indicating that binding an IPX socket failed. */ OF_SUBCLASSING_RESTRICTED @interface OFBindIPXSocketFailedException: OFBindSocketFailedException { uint16_t _port; uint8_t _packetType; } /** * @brief The IPX port on which binding failed. */ @property (readonly, nonatomic) uint16_t port; /** * @brief The IPX packet type for which binding failed. */ @property (readonly, nonatomic) uint8_t packetType; /** * @brief Creates a new, autoreleased bind IPX socket failed exception. * * @param port The IPX port to which binding failed * @param packetType The IPX packet type for which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind IPX socket failed exception */ + (instancetype)exceptionWithPort: (uint16_t)port packetType: (uint8_t)packetType socket: (id)socket errNo: (int)errNo; + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind IPX socket failed exception. * * @param port The IPX port to which binding failed * @param packetType The IPX packet type for which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return An initialized bind IPX socket failed exception */ - (instancetype)initWithPort: (uint16_t)port packetType: (uint8_t)packetType socket: (id)socket errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/exceptions/OFBindIPXSocketFailedException.m version [b4a5fc6e68].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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. */ #include "config.h" #import "OFBindIPXSocketFailedException.h" #import "OFString.h" @implementation OFBindIPXSocketFailedException @synthesize port = _port, packetType = _packetType; + (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithPort: (uint16_t)port packetType: (uint8_t)packetType socket: (id)sock errNo: (int)errNo { return [[[self alloc] initWithPort: port packetType: packetType socket: sock errNo: errNo] autorelease]; } - (instancetype)initWithSocket: (id)sock errNo: (int)errNo { OF_INVALID_INIT_METHOD } - (instancetype)initWithPort: (uint16_t)port packetType: (uint8_t)packetType socket: (id)sock errNo: (int)errNo { self = [super initWithSocket: sock errNo: errNo]; @try { _port = port; _packetType = packetType; } @catch (id e) { [self release]; @throw e; } return self; } - (OFString *)description { return [OFString stringWithFormat: @"Binding to port %" @PRIx16 @" for packet type %" @PRIx8 @" failed in socket of type %@: %@", _port, _packetType, [_socket class], OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFBindSocketFailedException.h from [27f2ca0058] to [36c8977d2e].
︙ | ︙ | |||
27 28 29 30 31 32 33 | * @class OFBindSocketFailedException \ * OFBindSocketFailedException.h ObjFW/OFBindSocketFailedException.h * * @brief An exception indicating that binding a socket failed. */ @interface OFBindSocketFailedException: OFException { | < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < | < < | < < | < < < < < < < < < | 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 73 | * @class OFBindSocketFailedException \ * OFBindSocketFailedException.h ObjFW/OFBindSocketFailedException.h * * @brief An exception indicating that binding a socket failed. */ @interface OFBindSocketFailedException: OFException { id _socket; int _errNo; OF_RESERVE_IVARS(OFBindSocketFailedException, 4) } /** * @brief The socket which could not be bound. */ @property (readonly, nonatomic) id socket; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased bind socket failed exception. * * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind socket failed exception */ + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind socket failed exception. * * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return An initialized bind socket failed exception */ - (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFBindSocketFailedException.m from [e3360ae495] to [6491b695d4].
︙ | ︙ | |||
15 16 17 18 19 20 21 | #include "config.h" #import "OFBindSocketFailedException.h" #import "OFString.h" @implementation OFBindSocketFailedException | < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | | < < < < < | 15 16 17 18 19 20 21 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 | #include "config.h" #import "OFBindSocketFailedException.h" #import "OFString.h" @implementation OFBindSocketFailedException @synthesize socket = _socket, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo { return [[[self alloc] initWithSocket: sock errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithSocket: (id)sock errNo: (int)errNo { self = [super init]; @try { _socket = [sock retain]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_socket release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Binding a socket of type %@ failed: %@", [_socket class], OFStrError(_errNo)]; } @end |
Added src/exceptions/OFBindUNIXSocketFailedException.h version [8dc7fd786c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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 "OFBindSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFBindUNIXSocketFailedException \ * OFBindUNIXSocketFailedException.h \ * ObjFW/OFBindUNIXSocketFailedException.h * * @brief An exception indicating that binding a UNIX socket failed. */ OF_SUBCLASSING_RESTRICTED @interface OFBindUNIXSocketFailedException: OFBindSocketFailedException { OFString *_Nullable _path; } /** * @brief The path on which binding failed. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; /** * @brief Creates a new, autoreleased bind UNIX socket failed exception. * * @param path The path on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind UNIX socket failed exception */ + (instancetype)exceptionWithPath: (OFString *)path socket: (id)socket errNo: (int)errNo; + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind UNIX socket failed exception. * * @param path The path on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return An initialized bind UNIX socket failed exception */ - (instancetype)initWithPath: (OFString *)path socket: (id)socket errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/exceptions/OFBindUNIXSocketFailedException.m version [e85a3193a3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * 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. */ #include "config.h" #import "OFBindUNIXSocketFailedException.h" #import "OFString.h" @implementation OFBindUNIXSocketFailedException @synthesize path = _path; + (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithPath: (OFString *)path socket: (id)sock errNo: (int)errNo { return [[[self alloc] initWithPath: path socket: sock errNo: errNo] autorelease]; } - (instancetype)initWithSocket: (id)sock errNo: (int)errNo { OF_INVALID_INIT_METHOD } - (instancetype)initWithPath: (OFString *)path socket: (id)sock errNo: (int)errNo { self = [super initWithSocket: sock errNo: errNo]; @try { _path = [path copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_path release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Binding to path %@ failed in socket of type %@: %@", _path, [_socket class], OFStrError(_errNo)]; } @end |