Index: src/OFDDPSocket.m ================================================================== --- src/OFDDPSocket.m +++ src/OFDDPSocket.m @@ -24,11 +24,11 @@ #import "OFDDPSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" +#import "OFBindDDPSocketFailedException.h" @implementation OFDDPSocket @dynamic delegate; - (OFSocketAddress)bindToPort: (uint8_t)port @@ -43,11 +43,11 @@ address = OFSocketAddressMakeAppleTalk(0, 0, port); if ((_socket = socket(address.sockaddr.at.sat_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) - @throw [OFBindFailedException + @throw [OFBindDDPSocketFailedException exceptionWithPort: port socket: self errNo: OFSocketErrNo()]; _canBlock = true; @@ -62,13 +62,14 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - socket: self - errNo: errNo]; + @throw [OFBindDDPSocketFailedException + exceptionWithPort: port + socket: self + errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyAppleTalk; address.length = (socklen_t)sizeof(address.sockaddr); @@ -78,22 +79,24 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - socket: self - errNo: errNo]; + @throw [OFBindDDPSocketFailedException + exceptionWithPort: port + socket: self + errNo: errNo]; } if (address.sockaddr.at.sat_family != AF_APPLETALK) { closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - socket: self - errNo: EAFNOSUPPORT]; + @throw [OFBindDDPSocketFailedException + exceptionWithPort: port + socket: self + errNo: EAFNOSUPPORT]; } return address; } @end Index: src/OFIPSocketAsyncConnector.m ================================================================== --- src/OFIPSocketAsyncConnector.m +++ src/OFIPSocketAsyncConnector.m @@ -21,11 +21,11 @@ #import "OFData.h" #import "OFTCPSocket.h" #import "OFThread.h" #import "OFTimer.h" -#import "OFConnectionFailedException.h" +#import "OFConnectIPSocketFailedException.h" #import "OFInvalidFormatException.h" @implementation OFIPSocketAsyncConnector - (instancetype)initWithSocket: (id)sock host: (OFString *)host @@ -124,14 +124,14 @@ [self didConnect]; } - (id)of_connectionFailedExceptionForErrNo: (int)errNo { - return [OFConnectionFailedException exceptionWithHost: _host - port: _port - socket: _socket - errNo: errNo]; + return [OFConnectIPSocketFailedException exceptionWithHost: _host + port: _port + socket: _socket + errNo: errNo]; } - (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode { OFSocketAddress address = *(const OFSocketAddress *) @@ -140,11 +140,11 @@ OFSocketAddressSetPort(&address, _port); if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { if (_socketAddressesIndex >= _socketAddresses.count) { - _exception = [[OFConnectionFailedException alloc] + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; [self didConnect]; @@ -185,11 +185,11 @@ } else { #endif [_socket of_closeSocket]; if (_socketAddressesIndex >= _socketAddresses.count) { - _exception = [[OFConnectionFailedException + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; [self didConnect]; Index: src/OFIPXSocket.h ================================================================== --- src/OFIPXSocket.h +++ src/OFIPXSocket.h @@ -65,16 +65,23 @@ /** * @brief Bind the socket to the specified network, node and port with the * specified packet type. * + * @param network The IPX network to bind to. 0 means the current network. + * @param node The IPX network to bind to. An all zero node means the + * computer's node. * @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 OFBindFailedException Binding failed + * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already bound */ -- (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType; +- (OFSocketAddress) + bindToNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (uint16_t)port + packetType: (uint8_t)packetType; @end OF_ASSUME_NONNULL_END Index: src/OFIPXSocket.m ================================================================== --- src/OFIPXSocket.m +++ src/OFIPXSocket.m @@ -24,42 +24,46 @@ #import "OFIPXSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" +#import "OFBindIPXSocketFailedException.h" @implementation OFIPXSocket @dynamic delegate; -- (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType +- (OFSocketAddress)bindToNetwork: (uint32_t)network + node: (const unsigned char [IPX_NODE_LEN])node + port: (uint16_t)port + packetType: (uint8_t)packetType { - const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; OFSocketAddress address; int protocol = 0; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; - address = OFSocketAddressMakeIPX(0, zeroNode, port); + address = OFSocketAddressMakeIPX(network, node, port); #ifdef OF_WINDOWS 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 [OFBindFailedException - exceptionWithPort: port - packetType: packetType - socket: self - errNo: OFSocketErrNo()]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: 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) @@ -71,14 +75,17 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: packetType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: packetType + socket: self + errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); @@ -88,24 +95,30 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: packetType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: packetType + socket: self + errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: packetType - socket: self - errNo: EAFNOSUPPORT]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: packetType + socket: self + errNo: EAFNOSUPPORT]; } return address; } Index: src/OFSPXSocket.h ================================================================== --- src/OFSPXSocket.h +++ src/OFSPXSocket.h @@ -50,11 +50,11 @@ * @param exception An exception that occurred while connecting, or nil on * success */ - (void)socket: (OFSPXSocket *)socket didConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port exception: (nullable id)exception; @end /** @@ -87,15 +87,15 @@ * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to - * @throw OFConnectionFailedException Connecting failed + * @throw OFConnectSPXSocketFailedException Connecting failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)connectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * @@ -103,11 +103,11 @@ * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * @@ -116,11 +116,11 @@ * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the async connect */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** @@ -131,11 +131,11 @@ * @param port The port (sometimes also called socket number) on the node to * connect to * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port block: (OFSPXSocketAsyncConnectBlock)block; /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. @@ -146,24 +146,30 @@ * connect to * @param runLoopMode The run loop mode in which to perform the async connect * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXSocketAsyncConnectBlock)block; #endif /** * @brief Bind the socket to the specified network, node and port. * + * @param network The IPX network to bind to. 0 means the current network. + * @param node The IPX network to bind to. An all zero node means the + * computer's node. * @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 OFBindFailedException Binding failed + * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ -- (OFSocketAddress)bindToPort: (uint16_t)port; +- (OFSocketAddress) + bindToNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (uint16_t)port; @end OF_ASSUME_NONNULL_END Index: src/OFSPXSocket.m ================================================================== --- src/OFSPXSocket.m +++ src/OFSPXSocket.m @@ -22,12 +22,12 @@ #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" -#import "OFConnectionFailedException.h" +#import "OFBindIPXSocketFailedException.h" +#import "OFConnectSPXSocketFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif @@ -54,11 +54,11 @@ #endif } - (instancetype)initWithSocket: (OFSPXSocket *)socket network: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port #ifdef OF_HAVE_BLOCKS block: (OFSPXSocketAsyncConnectBlock)block #endif ; @@ -66,11 +66,11 @@ @end @implementation OFSPXSocketAsyncConnectDelegate - (instancetype)initWithSocket: (OFSPXSocket *)sock network: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port #ifdef OF_HAVE_BLOCKS block: (OFSPXSocketAsyncConnectBlock)block #endif { @@ -164,15 +164,15 @@ #endif } - (id)of_connectionFailedExceptionForErrNo: (int)errNo { - return [OFConnectionFailedException exceptionWithNetwork: _network - node: _node - port: _port - socket: _socket - errNo: errNo]; + return [OFConnectSPXSocketFailedException exceptionWithNetwork: _network + node: _node + port: _port + socket: _socket + errNo: errNo]; } @end @implementation OFSPXSocket @dynamic delegate; @@ -222,48 +222,48 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; } - (void)connectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port { OFSocketAddress address = OFSocketAddressMakeIPX(network, node, port); int errNo; if (![self of_createSocketForAddress: &address errNo: &errNo]) - @throw [OFConnectionFailedException + @throw [OFConnectSPXSocketFailedException exceptionWithNetwork: network node: node port: port socket: self errNo: errNo]; if (![self of_connectSocketToAddress: &address errNo: &errNo]) { [self of_closeSocket]; - @throw [OFConnectionFailedException + @throw [OFConnectSPXSocketFailedException exceptionWithNetwork: network node: node port: port socket: self errNo: errNo]; } } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port { [self asyncConnectToNetwork: network node: node port: port runLoopMode: OFDefaultRunLoopMode]; } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode { void *pool = objc_autoreleasePoolPush(); @@ -280,11 +280,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port block: (OFSPXSocketAsyncConnectBlock)block { [self asyncConnectToNetwork: network node: node @@ -292,11 +292,11 @@ runLoopMode: OFDefaultRunLoopMode block: block]; } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXSocketAsyncConnectBlock)block { void *pool = objc_autoreleasePoolPush(); @@ -311,31 +311,34 @@ objc_autoreleasePoolPop(pool); } #endif -- (OFSocketAddress)bindToPort: (uint16_t)port +- (OFSocketAddress)bindToNetwork: (uint32_t)network + node: (const unsigned char [IPX_NODE_LEN])node + port: (uint16_t)port { - const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; - address = OFSocketAddressMakeIPX(0, zeroNode, port); + address = OFSocketAddressMakeIPX(network, node, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) - @throw [OFBindFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: OFSocketErrNo()]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: 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) @@ -347,14 +350,17 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); @@ -364,24 +370,30 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: EAFNOSUPPORT]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: EAFNOSUPPORT]; } return address; } @end Index: src/OFSPXStreamSocket.h ================================================================== --- src/OFSPXStreamSocket.h +++ src/OFSPXStreamSocket.h @@ -51,11 +51,11 @@ * @param exception An exception that occurred while connecting, or nil on * success */ - (void)socket: (OFSPXStreamSocket *)socket didConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port exception: (nullable id)exception; @end /** @@ -88,15 +88,15 @@ * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to - * @throw OFConnectionFailedException Connecting failed + * @throw OFConnectSPXSocketFailedException Connecting failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)connectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. @@ -105,11 +105,11 @@ * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. @@ -119,11 +119,11 @@ * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the async connect */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** @@ -135,11 +135,11 @@ * @param port The port (sometimes also called socket number) on the node to * connect to * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port block: (OFSPXStreamSocketAsyncConnectBlock)block; /** * @brief Asynchronously connect the OFSPXStreamSocket to the specified @@ -151,24 +151,30 @@ * connect to * @param runLoopMode The run loop mode in which to perform the async connect * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXStreamSocketAsyncConnectBlock)block; #endif /** * @brief Bind the socket to the specified network, node and port. * + * @param network The IPX network to bind to. 0 means the current network. + * @param node The IPX network to bind to. An all zero node means the + * computer's node. * @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 OFConnectionFailedException Binding failed + * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ -- (OFSocketAddress)bindToPort: (uint16_t)port; +- (OFSocketAddress) + bindToNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (uint16_t)port; @end OF_ASSUME_NONNULL_END Index: src/OFSPXStreamSocket.m ================================================================== --- src/OFSPXStreamSocket.m +++ src/OFSPXStreamSocket.m @@ -22,12 +22,12 @@ #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" -#import "OFConnectionFailedException.h" +#import "OFBindIPXSocketFailedException.h" +#import "OFConnectSPXSocketFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif @@ -55,11 +55,11 @@ #endif } - (instancetype)initWithSocket: (OFSPXStreamSocket *)socket network: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port #ifdef OF_HAVE_BLOCKS block: (OFSPXStreamSocketAsyncConnectBlock)block #endif ; @@ -67,11 +67,11 @@ @end @implementation OFSPXStreamSocketAsyncConnectDelegate - (instancetype)initWithSocket: (OFSPXStreamSocket *)sock network: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port #ifdef OF_HAVE_BLOCKS block: (OFSPXStreamSocketAsyncConnectBlock)block #endif { @@ -166,15 +166,15 @@ #endif } - (id)of_connectionFailedExceptionForErrNo: (int)errNo { - return [OFConnectionFailedException exceptionWithNetwork: _network - node: _node - port: _port - socket: _socket - errNo: errNo]; + return [OFConnectSPXSocketFailedException exceptionWithNetwork: _network + node: _node + port: _port + socket: _socket + errNo: errNo]; } @end @implementation OFSPXStreamSocket @dynamic delegate; @@ -224,48 +224,48 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; } - (void)connectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port { OFSocketAddress address = OFSocketAddressMakeIPX(network, node, port); int errNo; if (![self of_createSocketForAddress: &address errNo: &errNo]) - @throw [OFConnectionFailedException + @throw [OFConnectSPXSocketFailedException exceptionWithNetwork: network node: node port: port socket: self errNo: errNo]; if (![self of_connectSocketToAddress: &address errNo: &errNo]) { [self of_closeSocket]; - @throw [OFConnectionFailedException + @throw [OFConnectSPXSocketFailedException exceptionWithNetwork: network node: node port: port socket: self errNo: errNo]; } } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port { [self asyncConnectToNetwork: network node: node port: port runLoopMode: OFDefaultRunLoopMode]; } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode { void *pool = objc_autoreleasePoolPush(); @@ -282,11 +282,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port block: (OFSPXStreamSocketAsyncConnectBlock)block { [self asyncConnectToNetwork: network node: node @@ -294,11 +294,11 @@ runLoopMode: OFDefaultRunLoopMode block: block]; } - (void)asyncConnectToNetwork: (uint32_t)network - node: (unsigned char [_Nonnull IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXStreamSocketAsyncConnectBlock)block { void *pool = objc_autoreleasePoolPush(); @@ -313,30 +313,33 @@ objc_autoreleasePoolPop(pool); } #endif -- (OFSocketAddress)bindToPort: (uint16_t)port +- (OFSocketAddress)bindToNetwork: (uint32_t)network + node: (const unsigned char [IPX_NODE_LEN])node + port: (uint16_t)port { - const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; - address = OFSocketAddressMakeIPX(0, zeroNode, port); + address = OFSocketAddressMakeIPX(network, node, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) - @throw [OFBindFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: OFSocketErrNo()]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: 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) @@ -348,14 +351,17 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); @@ -365,24 +371,30 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: EAFNOSUPPORT]; + @throw [OFBindIPXSocketFailedException + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: EAFNOSUPPORT]; } return address; } @end Index: src/OFSequencedPacketSocket.h ================================================================== --- src/OFSequencedPacketSocket.h +++ src/OFSequencedPacketSocket.h @@ -303,28 +303,28 @@ /** * @brief Listen on the socket. * * @param backlog Maximum length for the queue of pending connections. - * @throw OFListenFailedException Listening failed + * @throw OFListenOnSocketFailedException Listening failed * @throw OFNotOpenException The socket is not open */ - (void)listenWithBacklog: (int)backlog; /** * @brief Listen on the socket. * - * @throw OFListenFailedException Listening failed + * @throw OFListenOnSocketFailedException Listening failed * @throw OFNotOpenException The socket is not open */ - (void)listen; /** * @brief Accept an incoming connection. * * @return An autoreleased sequenced packet socket for the accepted connection. - * @throw OFAcceptFailedException Accepting failed + * @throw OFAcceptSocketFailedException Accepting failed * @throw OFNotOpenException The socket is not open */ - (instancetype)accept; /** Index: src/OFSequencedPacketSocket.m ================================================================== --- src/OFSequencedPacketSocket.m +++ src/OFSequencedPacketSocket.m @@ -33,14 +33,14 @@ #import "OFRunLoop+Private.h" #import "OFRunLoop.h" #import "OFSocket.h" #import "OFSocket+Private.h" -#import "OFAcceptFailedException.h" +#import "OFAcceptSocketFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" -#import "OFListenFailedException.h" +#import "OFListenOnSocketFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" @@ -306,11 +306,11 @@ { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (listen(_socket, backlog) == -1) - @throw [OFListenFailedException + @throw [OFListenOnSocketFailedException exceptionWithSocket: self backlog: backlog errNo: OFSocketErrNo()]; _listening = true; @@ -335,26 +335,26 @@ #if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC) if ((client->_socket = paccept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, SOCK_CLOEXEC)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #else if ((client->_socket = accept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) Index: src/OFSocket.h ================================================================== --- src/OFSocket.h +++ src/OFSocket.h @@ -340,11 +340,11 @@ * @brief Gets the IPX node of the specified @ref OFSocketAddress. * * @param address The address on which to get the IPX node * @param node A byte array to store the IPX node of the address */ -extern void OFSocketAddressIPXNode(const OFSocketAddress *_Nonnull address, +extern void OFSocketAddressGetIPXNode(const OFSocketAddress *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN]); /** * @brief Sets the AppleTalk network of the specified @ref OFSocketAddress. * Index: src/OFSocket.m ================================================================== --- src/OFSocket.m +++ src/OFSocket.m @@ -979,11 +979,11 @@ memcpy(address->sockaddr.ipx.sipx_node, node, IPX_NODE_LEN); } void -OFSocketAddressIPXNode(const OFSocketAddress *address, +OFSocketAddressGetIPXNode(const OFSocketAddress *address, unsigned char node[IPX_NODE_LEN]) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; Index: src/OFStreamSocket.h ================================================================== --- src/OFStreamSocket.h +++ src/OFStreamSocket.h @@ -104,28 +104,28 @@ /** * @brief Listen on the socket. * * @param backlog Maximum length for the queue of pending connections. - * @throw OFListenFailedException Listening failed + * @throw OFListenOnSocketFailedException Listening failed * @throw OFNotOpenException The socket is not open */ - (void)listenWithBacklog: (int)backlog; /** * @brief Listen on the socket. * - * @throw OFListenFailedException Listening failed + * @throw OFListenOnSocketFailedException Listening failed * @throw OFNotOpenException The socket is not open */ - (void)listen; /** * @brief Accept an incoming connection. * * @return An autoreleased OFStreamSocket for the accepted connection. - * @throw OFAcceptFailedException Accepting failed + * @throw OFAcceptSocketFailedException Accepting failed * @throw OFNotOpenException The socket is not open */ - (instancetype)accept; /** Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -29,14 +29,14 @@ #import "OFStreamSocket+Private.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket+Private.h" -#import "OFAcceptFailedException.h" +#import "OFAcceptSocketFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" -#import "OFListenFailedException.h" +#import "OFListenOnSocketFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" @@ -231,11 +231,11 @@ { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (listen(_socket, backlog) == -1) - @throw [OFListenFailedException + @throw [OFListenOnSocketFailedException exceptionWithSocket: self backlog: backlog errNo: OFSocketErrNo()]; _listening = true; @@ -256,26 +256,26 @@ #if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC) if ((client->_socket = paccept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, (struct sockaddr * )&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, SOCK_CLOEXEC)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #else if ((client->_socket = accept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length)) == OFInvalidSocketHandle) - @throw [OFAcceptFailedException + @throw [OFAcceptSocketFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -154,11 +154,11 @@ /** * @brief Connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to - * @throw OFConnectionFailedException Connecting failed + * @throw OFConnectIPSocketFailedException Connecting failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)connectToHost: (OFString *)host port: (uint16_t)port; /** @@ -212,12 +212,12 @@ * @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 OFBindFailedException Binding failed + * @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 Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -42,11 +42,11 @@ #import "OFString.h" #import "OFTCPSocketSOCKS5Connector.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" +#import "OFBindIPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFSetOptionFailedException.h" @@ -314,11 +314,11 @@ OFSocketAddressSetPort(&address, port); if ((_socket = socket( ((struct sockaddr *)&address.sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: OFSocketErrNo()]; @@ -340,14 +340,15 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithHost: host - port: port - socket: self - errNo: errNo]; + @throw [OFBindIPSocketFailedException + exceptionWithHost: host + port: port + socket: self + errNo: errNo]; } #if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) } else { for (;;) { uint16_t rnd = 0; @@ -369,11 +370,11 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } @@ -395,14 +396,14 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithHost: host - port: port - socket: self - errNo: errNo]; + @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); @@ -412,22 +413,23 @@ # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithHost: host - port: port - socket: self - errNo: EAFNOSUPPORT]; + @throw [OFBindIPSocketFailedException + exceptionWithHost: host + port: port + socket: self + errNo: EAFNOSUPPORT]; } #else closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithHost: host - port: port - socket: self - errNo: EADDRNOTAVAIL]; + @throw [OFBindIPSocketFailedException exceptionWithHost: host + port: port + socket: self + errNo: EADDRNOTAVAIL]; #endif } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) - (void)setSendsKeepAlives: (bool)sendsKeepAlives Index: src/OFTCPSocketSOCKS5Connector.m ================================================================== --- src/OFTCPSocketSOCKS5Connector.m +++ src/OFTCPSocketSOCKS5Connector.m @@ -21,11 +21,11 @@ #import "OFTCPSocketSOCKS5Connector.h" #import "OFData.h" #import "OFRunLoop.h" #import "OFString.h" -#import "OFConnectionFailedException.h" +#import "OFConnectIPSocketFailedException.h" enum { stateSendAuthentication = 1, stateReadVersion, stateSendRequest, @@ -142,11 +142,11 @@ switch (_SOCKS5State) { case stateReadVersion: SOCKSVersion = buffer; if (SOCKSVersion[0] != 5 || SOCKSVersion[1] != 0) { - _exception = [[OFConnectionFailedException alloc] + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: self errNo: EPROTONOSUPPORT]; [self didConnect]; @@ -171,11 +171,11 @@ return false; case stateReadResponse: response = buffer; if (response[0] != 5 || response[2] != 0) { - _exception = [[OFConnectionFailedException alloc] + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: self errNo: EPROTONOSUPPORT]; [self didConnect]; @@ -214,11 +214,11 @@ errNo = 0; #endif break; } - _exception = [[OFConnectionFailedException alloc] + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; [self didConnect]; @@ -244,11 +244,11 @@ [_socket asyncReadIntoBuffer: _buffer exactLength: 16 + 2 runLoopMode: runLoopMode]; return false; default: - _exception = [[OFConnectionFailedException alloc] + _exception = [[OFConnectIPSocketFailedException alloc] initWithHost: _host port: _port socket: self errNo: EPROTONOSUPPORT]; [self didConnect]; Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -70,12 +70,12 @@ * @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 OFBindFailedException Binding failed + * @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 Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -33,11 +33,11 @@ #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFThread.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" +#import "OFBindIPSocketFailedException.h" @implementation OFUDPSocket @dynamic delegate; - (uint16_t)of_bindToAddress: (OFSocketAddress *)address @@ -50,11 +50,11 @@ #endif if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle) - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: OFSocketErrNo()]; @@ -75,11 +75,11 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: errNo]; } @@ -105,11 +105,11 @@ port = OFSocketAddressPort(address); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } @@ -131,11 +131,11 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: errNo]; } @@ -149,21 +149,21 @@ # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: EAFNOSUPPORT]; } #else closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException + @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressPort(address) socket: self errNo: EADDRNOTAVAIL]; #endif Index: src/OFUNIXDatagramSocket.h ================================================================== --- src/OFUNIXDatagramSocket.h +++ src/OFUNIXDatagramSocket.h @@ -63,12 +63,12 @@ /** * @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 OFBindFailedException Binding failed + * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already bound */ - (OFSocketAddress)bindToPath: (OFString *)path; @end OF_ASSUME_NONNULL_END Index: src/OFUNIXDatagramSocket.m ================================================================== --- src/OFUNIXDatagramSocket.m +++ src/OFUNIXDatagramSocket.m @@ -23,11 +23,11 @@ #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" +#import "OFBindUNIXSocketFailedException.h" @implementation OFUNIXDatagramSocket @dynamic delegate; - (OFSocketAddress)bindToPath: (OFString *)path @@ -42,11 +42,11 @@ address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) - @throw [OFBindFailedException + @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = true; @@ -61,13 +61,14 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPath: path - socket: self - errNo: errNo]; + @throw [OFBindUNIXSocketFailedException + exceptionWithPath: path + socket: self + errNo: errNo]; } return address; } @end Index: src/OFUNIXStreamSocket.h ================================================================== --- src/OFUNIXStreamSocket.h +++ src/OFUNIXStreamSocket.h @@ -52,21 +52,21 @@ /** * @brief Connects the OFUNIXStreamSocket to the specified destination. * * @param path The path to connect to - * @throw OFConnectionFailedException Connecting failed + * @throw OFConnectUNIXSocketFailedException Connecting failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)connectToPath: (OFString *)path; /** * @brief Binds the socket to the specified host and port. * * @param path The path to bind to - * @throw OFBindFailedException Binding failed + * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyConnectedException The socket is already connected or bound */ - (void)bindToPath: (OFString *)path; @end OF_ASSUME_NONNULL_END Index: src/OFUNIXStreamSocket.m ================================================================== --- src/OFUNIXStreamSocket.m +++ src/OFUNIXStreamSocket.m @@ -23,12 +23,12 @@ #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyConnectedException.h" -#import "OFBindFailedException.h" -#import "OFConnectionFailedException.h" +#import "OFBindUNIXSocketFailedException.h" +#import "OFConnectUNIXSocketFailedException.h" @implementation OFUNIXStreamSocket @dynamic delegate; - (void)connectToPath: (OFString *)path @@ -43,11 +43,11 @@ address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) - @throw [OFConnectionFailedException + @throw [OFConnectUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = true; @@ -62,13 +62,14 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFConnectionFailedException exceptionWithPath: path - socket: self - errNo: errNo]; + @throw [OFConnectUNIXSocketFailedException + exceptionWithPath: path + socket: self + errNo: errNo]; } } - (void)bindToPath: (OFString *)path { @@ -82,11 +83,11 @@ address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) - @throw [OFBindFailedException + @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = true; @@ -101,11 +102,12 @@ int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; - @throw [OFBindFailedException exceptionWithPath: path - socket: self - errNo: errNo]; + @throw [OFBindUNIXSocketFailedException + exceptionWithPath: path + socket: self + errNo: errNo]; } } @end Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -143,13 +143,23 @@ #endif #import "OFAllocFailedException.h" #import "OFException.h" #ifdef OF_HAVE_SOCKETS -# import "OFAcceptFailedException.h" +# import "OFAcceptSocketFailedException.h" # import "OFAlreadyConnectedException.h" -# import "OFBindFailedException.h" +# import "OFBindSocketFailedException.h" +# import "OFBindIPSocketFailedException.h" +# ifdef OF_HAVE_UNIX_SOCKETS +# import "OFBindUNIXSocketFailedException.h" +# endif +# ifdef OF_HAVE_IPX +# import "OFBindIPXSocketFailedException.h" +# endif +# ifdef OF_HAVE_APPLETALK +# import "OFBindDDPSocketFailedException.h" +# endif #endif #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" #ifdef OF_HAVE_THREADS # import "OFConditionBroadcastFailedException.h" @@ -156,11 +166,18 @@ # import "OFConditionSignalFailedException.h" # import "OFConditionStillWaitingException.h" # import "OFConditionWaitFailedException.h" #endif #ifdef OF_HAVE_SOCKETS -# import "OFConnectionFailedException.h" +# import "OFConnectSocketFailedException.h" +# import "OFConnectIPSocketFailedException.h" +# ifdef OF_HAVE_UNIX_SOCKETS +# import "OFConnectUNIXSocketFailedException.h" +# endif +# ifdef OF_HAVE_IPX +# import "OFConnectSPXSocketFailedException.h" +# endif #endif #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #ifdef OF_WINDOWS @@ -193,11 +210,11 @@ #import "OFInvalidFormatException.h" #import "OFInvalidJSONException.h" #import "OFInvalidServerResponseException.h" #import "OFLinkItemFailedException.h" #ifdef OF_HAVE_SOCKETS -# import "OFListenFailedException.h" +# import "OFListenOnSocketFailedException.h" #endif #ifdef OF_HAVE_PLUGINS # import "OFLoadPluginFailedException.h" #endif #import "OFLockFailedException.h" Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -51,20 +51,30 @@ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \ OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m -SRCS_SOCKETS = OFAcceptFailedException.m \ +SRCS_SOCKETS = OFAcceptSocketFailedException.m \ OFAlreadyConnectedException.m \ - OFBindFailedException.m \ - OFConnectionFailedException.m \ + OFBindIPSocketFailedException.m \ + OFBindSocketFailedException.m \ + OFConnectIPSocketFailedException.m \ + OFConnectSocketFailedException.m \ OFDNSQueryFailedException.m \ OFHTTPRequestFailedException.m \ - OFListenFailedException.m \ + OFListenOnSocketFailedException.m \ OFObserveKernelEventsFailedException.m \ OFResolveHostFailedException.m \ - OFTLSHandshakeFailedException.m + OFTLSHandshakeFailedException.m \ + ${USE_SRCS_APPLETALK} \ + ${USE_SRCS_IPX} \ + ${USE_SRCS_UNIX_SOCKETS} +SRCS_APPLETALK = OFBindDDPSocketFailedException.m +SRCS_IPX = OFBindIPXSocketFailedException.m \ + OFConnectSPXSocketFailedException.m +SRCS_UNIX_SOCKETS = OFBindUNIXSocketFailedException.m \ + OFConnectUNIXSocketFailedException.m SRCS_THREADS = OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ OFConditionStillWaitingException.m \ OFConditionWaitFailedException.m \ OFThreadJoinFailedException.m \ DELETED src/exceptions/OFAcceptFailedException.h Index: src/exceptions/OFAcceptFailedException.h ================================================================== --- src/exceptions/OFAcceptFailedException.h +++ src/exceptions/OFAcceptFailedException.h @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFException.h" - -#ifndef OF_HAVE_SOCKETS -# error No sockets available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFAcceptFailedException \ - * OFAcceptFailedException.h ObjFW/OFAcceptFailedException.h - * - * @brief An exception indicating that accepting a connection failed. - */ -@interface OFAcceptFailedException: OFException -{ - id _socket; - int _errNo; - OF_RESERVE_IVARS(OFAcceptFailedException, 4) -} - -/** - * @brief The socket which could not accept a connection. - */ -@property (readonly, nonatomic) id socket; - -/** - * @brief The errno from when the exception was created. - */ -@property (readonly, nonatomic) int errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Creates a new, autoreleased accept failed exception. - * - * @param socket The socket which could not accept a connection - * @param errNo The errno for the error - * @return A new, autoreleased accept failed exception - */ -+ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; - -- (instancetype)init OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated accept failed exception. - * - * @param socket The socket which could not accept a connection - * @param errNo The errno for the error - * @return An initialized accept failed exception - */ -- (instancetype)initWithSocket: (id)socket - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFAcceptFailedException.m Index: src/exceptions/OFAcceptFailedException.m ================================================================== --- src/exceptions/OFAcceptFailedException.m +++ src/exceptions/OFAcceptFailedException.m @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFAcceptFailedException.h" -#import "OFString.h" - -@implementation OFAcceptFailedException -@synthesize socket = _socket, errNo = _errNo; - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo -{ - return [[[self alloc] initWithSocket: socket errNo: errNo] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithSocket: (id)socket errNo: (int)errNo -{ - self = [super init]; - - _socket = [socket retain]; - _errNo = errNo; - - return self; -} - -- (void)dealloc -{ - [_socket release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Failed to accept connection in socket of class %@: %@", - [_socket class], OFStrError(_errNo)]; -} -@end ADDED src/exceptions/OFAcceptSocketFailedException.h Index: src/exceptions/OFAcceptSocketFailedException.h ================================================================== --- src/exceptions/OFAcceptSocketFailedException.h +++ src/exceptions/OFAcceptSocketFailedException.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFException.h" + +#ifndef OF_HAVE_SOCKETS +# error No sockets available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFAcceptSocketFailedException \ + * OFAcceptSocketFailedException.h ObjFW/OFAcceptSocketFailedException.h + * + * @brief An exception indicating that accepting a connection failed. + */ +@interface OFAcceptSocketFailedException: OFException +{ + id _socket; + int _errNo; + OF_RESERVE_IVARS(OFAcceptSocketFailedException, 4) +} + +/** + * @brief The socket which could not accept a connection. + */ +@property (readonly, nonatomic) id socket; + +/** + * @brief The errno from when the exception was created. + */ +@property (readonly, nonatomic) int errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Creates a new, autoreleased accept failed exception. + * + * @param socket The socket which could not accept a connection + * @param errNo The errno for the error + * @return A new, autoreleased accept failed exception + */ ++ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; + +- (instancetype)init OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated accept failed exception. + * + * @param socket The socket which could not accept a connection + * @param errNo The errno for the error + * @return An initialized accept failed exception + */ +- (instancetype)initWithSocket: (id)socket + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFAcceptSocketFailedException.m Index: src/exceptions/OFAcceptSocketFailedException.m ================================================================== --- src/exceptions/OFAcceptSocketFailedException.m +++ src/exceptions/OFAcceptSocketFailedException.m @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFAcceptSocketFailedException.h" +#import "OFString.h" + +@implementation OFAcceptSocketFailedException +@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]; + + _socket = [sock retain]; + _errNo = errNo; + + return self; +} + +- (void)dealloc +{ + [_socket release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Failed to accept connection in socket of class %@: %@", + [_socket class], OFStrError(_errNo)]; +} +@end Index: src/exceptions/OFAlreadyConnectedException.m ================================================================== --- src/exceptions/OFAlreadyConnectedException.m +++ src/exceptions/OFAlreadyConnectedException.m @@ -19,25 +19,25 @@ #import "OFString.h" @implementation OFAlreadyConnectedException @synthesize socket = _socket; -+ (instancetype)exceptionWithSocket: (id)socket ++ (instancetype)exceptionWithSocket: (id)sock { - return [[[self alloc] initWithSocket: socket] autorelease]; + return [[[self alloc] initWithSocket: sock] autorelease]; } - (instancetype)init { return [self initWithSocket: nil]; } -- (instancetype)initWithSocket: (id)socket +- (instancetype)initWithSocket: (id)sock { self = [super init]; - _socket = [socket retain]; + _socket = [sock retain]; return self; } - (void)dealloc ADDED src/exceptions/OFBindDDPSocketFailedException.h Index: src/exceptions/OFBindDDPSocketFailedException.h ================================================================== --- src/exceptions/OFBindDDPSocketFailedException.h +++ src/exceptions/OFBindDDPSocketFailedException.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 OFBindDDPSocketFailedException \ + * OFBindDDPSocketFailedException.h \ + * ObjFW/OFBindDDPSocketFailedException.h + * + * @brief An exception indicating that binding a DDP socket failed. + */ +OF_SUBCLASSING_RESTRICTED +@interface OFBindDDPSocketFailedException: OFBindSocketFailedException +{ + uint8_t _port; +} + +/** + * @brief The DDP port on which binding failed. + */ +@property (readonly, nonatomic) uint8_t port; + +/** + * @brief Creates a new, autoreleased bind DDP socket failed exception. + * + * @param port The DDP port to 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 DDP socket failed exception + */ ++ (instancetype)exceptionWithPort: (uint8_t)port + socket: (id)socket + errNo: (int)errNo; + ++ (instancetype)exceptionWithSocket: (id)socket + errNo: (int)errNo OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated bind DDP socket failed exception. + * + * @param port The DDP port to 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 DDP socket failed exception + */ +- (instancetype)initWithPort: (uint8_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/OFBindDDPSocketFailedException.m Index: src/exceptions/OFBindDDPSocketFailedException.m ================================================================== --- src/exceptions/OFBindDDPSocketFailedException.m +++ src/exceptions/OFBindDDPSocketFailedException.m @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFBindDDPSocketFailedException.h" +#import "OFData.h" +#import "OFString.h" + +@implementation OFBindDDPSocketFailedException +@synthesize port = _port; + ++ (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype)exceptionWithPort: (uint8_t)port + socket: (id)sock + errNo: (int)errNo +{ + return [[[self alloc] initWithPort: port + socket: sock + errNo: errNo] autorelease]; +} + +- (instancetype)initWithSocket: (id)sock errNo: (int)errNo +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithPort: (uint8_t)port + socket: (id)sock + errNo: (int)errNo +{ + self = [super initWithSocket: sock errNo: errNo]; + + @try { + _port = port; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Binding to port %" @PRIx8 @" failed in socket of type %@: %@", + _port, [_socket class], OFStrError(_errNo)]; +} +@end DELETED src/exceptions/OFBindFailedException.h Index: src/exceptions/OFBindFailedException.h ================================================================== --- src/exceptions/OFBindFailedException.h +++ src/exceptions/OFBindFailedException.h @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFException.h" - -#ifndef OF_HAVE_SOCKETS -# error No sockets available! -#endif - -#import "OFSocket.h" - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFBindFailedException \ - * OFBindFailedException.h ObjFW/OFBindFailedException.h - * - * @brief An exception indicating that binding a socket failed. - */ -@interface OFBindFailedException: OFException -{ - /* IP */ - OFString *_Nullable _host; - uint16_t _port; - /* IPX */ - uint8_t _packetType; - /* UNIX socket */ - OFString *_Nullable _path; - id _socket; - int _errNo; - OF_RESERVE_IVARS(OFBindFailedException, 4) -} - -/** - * @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 The IPX packet type for which binding failed. - */ -@property (readonly, nonatomic) uint8_t packetType; - -/** - * @brief The path on which binding failed. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; - -/** - * @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 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 failed exception - */ -+ (instancetype)exceptionWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Creates a new, autoreleased bind 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 failed exception - */ -+ (instancetype)exceptionWithPath: (OFString *)path - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Creates a new, autoreleased bind failed exception. - * - * @param port The port to 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 failed exception - */ -+ (instancetype)exceptionWithPort: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Creates a new, autoreleased bind failed exception. - * - * @param port The 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 failed exception - */ -+ (instancetype)exceptionWithPort: (uint16_t)port - packetType: (uint8_t)packetType - socket: (id)socket - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated bind 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 failed exception - */ -- (instancetype)initWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; -/** - * @brief Initializes an already allocated bind 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 failed exception - */ -- (instancetype)initWithPath: (OFString *)path - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Initializes an already allocated bind failed exception. - * - * @param port The port to 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 failed exception - */ -- (instancetype)initWithPort: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Initializes an already allocated bind failed exception. - * - * @param port The 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 failed exception - */ -- (instancetype)initWithPort: (uint16_t)port - packetType: (uint8_t)packetType - socket: (id)socket - errNo: (int)errNo; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFBindFailedException.m Index: src/exceptions/OFBindFailedException.m ================================================================== --- src/exceptions/OFBindFailedException.m +++ src/exceptions/OFBindFailedException.m @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFBindFailedException.h" -#import "OFString.h" - -@implementation OFBindFailedException -@synthesize host = _host, port = _port, packetType = _packetType, path = _path; -@synthesize socket = _socket, errNo = _errNo; - -+ (instancetype)exception -{ - 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)exceptionWithPath: (OFString *)path - socket: (id)sock - errNo: (int)errNo -{ - return [[[self alloc] initWithPath: path - socket: sock - errNo: errNo] autorelease]; -} - -+ (instancetype)exceptionWithPort: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - return [[[self alloc] initWithPort: port - socket: sock - errNo: errNo] autorelease]; -} - -+ (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)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _host = [host copy]; - _port = port; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (instancetype)initWithPath: (OFString *)path - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _path = [path copy]; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (instancetype)initWithPort: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - return [self initWithPort: port - packetType: 0 - socket: sock - errNo: errNo]; -} - -- (instancetype)initWithPort: (uint16_t)port - packetType: (uint8_t)packetType - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _port = port; - _packetType = packetType; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (void)dealloc -{ - [_host release]; - [_path release]; - [_socket release]; - - [super dealloc]; -} - -- (OFString *)description -{ - if (_path != nil) - return [OFString stringWithFormat: - @"Binding to path %@ failed in socket of type %@: %@", - _path, [_socket class], OFStrError(_errNo)]; - else if (_host != nil) - return [OFString stringWithFormat: - @"Binding to port %" @PRIu16 @" on host %@ failed in " - @"socket of type %@: %@", - _port, _host, [_socket class], OFStrError(_errNo)]; - else if (_port != 0) - return [OFString stringWithFormat: - @"Binding to port %" @PRIx16 @" for packet type %" @PRIx8 - @" failed in socket of type %@: %@", - _port, _packetType, [_socket class], OFStrError(_errNo)]; - else - return [OFString stringWithFormat: - @"Binding to port %" @PRIx16 @" failed in socket of type " - @"%@: %@", - _port, [_socket class], OFStrError(_errNo)]; -} -@end ADDED src/exceptions/OFBindIPSocketFailedException.h Index: src/exceptions/OFBindIPSocketFailedException.h ================================================================== --- src/exceptions/OFBindIPSocketFailedException.h +++ src/exceptions/OFBindIPSocketFailedException.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 Index: src/exceptions/OFBindIPSocketFailedException.m ================================================================== --- src/exceptions/OFBindIPSocketFailedException.m +++ src/exceptions/OFBindIPSocketFailedException.m @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 Index: src/exceptions/OFBindIPXSocketFailedException.h ================================================================== --- src/exceptions/OFBindIPXSocketFailedException.h +++ src/exceptions/OFBindIPXSocketFailedException.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 +{ + uint32_t _network; + unsigned char _node[IPX_NODE_LEN]; + uint16_t _port; + uint8_t _packetType; +} + +/** + * @brief The IPX network on which binding failed. + */ +@property (readonly, nonatomic) uint32_t network; + +/** + * @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 network The IPX network to which binding failed + * @param node The IPX node to which binding failed + * @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) + exceptionWithNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (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 network The IPX network to which binding failed + * @param node The IPX node to which binding failed + * @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) + initWithNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (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; + +/** + * @brief Get the IPX node for which binding failed. + * + * @param node A pointer to where to write the node to + */ +- (void)getNode: (unsigned char [_Nonnull IPX_NODE_LEN])node; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFBindIPXSocketFailedException.m Index: src/exceptions/OFBindIPXSocketFailedException.m ================================================================== --- src/exceptions/OFBindIPXSocketFailedException.m +++ src/exceptions/OFBindIPXSocketFailedException.m @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFBindIPXSocketFailedException.h" +#import "OFData.h" +#import "OFString.h" + +@implementation OFBindIPXSocketFailedException +@synthesize network = _network, port = _port, packetType = _packetType; + ++ (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype) + exceptionWithNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (uint16_t)port + packetType: (uint8_t)packetType + socket: (id)sock + errNo: (int)errNo +{ + return [[[self alloc] initWithNetwork: network + node: node + port: port + packetType: packetType + socket: sock + errNo: errNo] autorelease]; +} + +- (instancetype)initWithSocket: (id)sock errNo: (int)errNo +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype) + initWithNetwork: (uint32_t)network + node: (const unsigned char [_Nonnull IPX_NODE_LEN])node + port: (uint16_t)port + packetType: (uint8_t)packetType + socket: (id)sock + errNo: (int)errNo +{ + self = [super initWithSocket: sock errNo: errNo]; + + @try { + _network = network; + memcpy(_node, node, sizeof(_node)); + _port = port; + _packetType = packetType; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)getNode: (unsigned char [IPX_NODE_LEN])node +{ + memcpy(node, _node, sizeof(_node)); +} + +- (OFString *)description +{ + OFData *node = [OFData dataWithItems: _node count: sizeof(_node)]; + + return [OFString stringWithFormat: + @"Binding to network %" @PRIx16 " on node %@ with port %" @PRIx16 + @" failed for packet type %" @PRIx8 " in socket of type %@: %@", + _network, node, _port, _packetType, [_socket class], + OFStrError(_errNo)]; +} +@end ADDED src/exceptions/OFBindSocketFailedException.h Index: src/exceptions/OFBindSocketFailedException.h ================================================================== --- src/exceptions/OFBindSocketFailedException.h +++ src/exceptions/OFBindSocketFailedException.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFException.h" + +#ifndef OF_HAVE_SOCKETS +# error No sockets available! +#endif + +#import "OFSocket.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @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 ADDED src/exceptions/OFBindSocketFailedException.m Index: src/exceptions/OFBindSocketFailedException.m ================================================================== --- src/exceptions/OFBindSocketFailedException.m +++ src/exceptions/OFBindSocketFailedException.m @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "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 Index: src/exceptions/OFBindUNIXSocketFailedException.h ================================================================== --- src/exceptions/OFBindUNIXSocketFailedException.h +++ src/exceptions/OFBindUNIXSocketFailedException.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 Index: src/exceptions/OFBindUNIXSocketFailedException.m ================================================================== --- src/exceptions/OFBindUNIXSocketFailedException.m +++ src/exceptions/OFBindUNIXSocketFailedException.m @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 ADDED src/exceptions/OFConnectIPSocketFailedException.h Index: src/exceptions/OFConnectIPSocketFailedException.h ================================================================== --- src/exceptions/OFConnectIPSocketFailedException.h +++ src/exceptions/OFConnectIPSocketFailedException.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectSocketFailedException.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFConnectIPSocketFailedException \ + * OFConnectIPSocketFailedException.h \ + * ObjFW/OFConnectIPSocketFailedException.h + * + * @brief An exception indicating that an IP connection could not be + * established. + */ +OF_SUBCLASSING_RESTRICTED +@interface OFConnectIPSocketFailedException: OFConnectSocketFailedException +{ + OFString *_Nullable _host; + uint16_t _port; +} + +/** + * @brief The host to which the connection failed. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *host; + +/** + * @brief The port on the host to which the connection failed. + */ +@property (readonly, nonatomic) uint16_t port; + +/** + * @brief Creates a new, autoreleased connect IP socket failed exception. + * + * @param host The host to which the connection failed + * @param port The port on the host to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return A new, autoreleased connect 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 connect IP socket failed exception. + * + * @param host The host to which the connection failed + * @param port The port on the host to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return An initialized connect 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/OFConnectIPSocketFailedException.m Index: src/exceptions/OFConnectIPSocketFailedException.m ================================================================== --- src/exceptions/OFConnectIPSocketFailedException.m +++ src/exceptions/OFConnectIPSocketFailedException.m @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectIPSocketFailedException.h" +#import "OFString.h" + +@implementation OFConnectIPSocketFailedException +@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: + @"A connection to %@ on port %" @PRIu16 @" could not be " + @"established in socket of type %@: %@", + _host, _port, [_socket class], OFStrError(_errNo)]; +} +@end ADDED src/exceptions/OFConnectSPXSocketFailedException.h Index: src/exceptions/OFConnectSPXSocketFailedException.h ================================================================== --- src/exceptions/OFConnectSPXSocketFailedException.h +++ src/exceptions/OFConnectSPXSocketFailedException.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectSocketFailedException.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFConnectSPXSocketFailedException \ + * OFConnectSPXSocketFailedException.h \ + * ObjFW/OFConnectSocketFailedException.h + * + * @brief An exception indicating that an SPX connection could not be + * established. + */ +OF_SUBCLASSING_RESTRICTED +@interface OFConnectSPXSocketFailedException: OFConnectSocketFailedException +{ + uint32_t _network; + unsigned char _node[IPX_NODE_LEN]; + uint16_t _port; +} + + +/** + * @brief The IPX network of the node to which the connection failed. + */ +@property (readonly, nonatomic) uint32_t network; + +/** + * @brief The IPX port on the host to which the connection failed. + */ +@property (readonly, nonatomic) uint16_t port; + +/** + * @brief Creates a new, autoreleased connect SPX socket failed exception. + * + * @param network The IPX network of the node to which the connection failed + * @param node The node to which the connection failed + * @param port The port on the node to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return A new, autoreleased connect SPX socket failed exception + */ ++ (instancetype) + exceptionWithNetwork: (uint32_t)network + node: (const unsigned char [_Nullable IPX_NODE_LEN])node + port: (uint16_t)port + socket: (id)socket + errNo: (int)errNo; + ++ (instancetype)exceptionWithSocket: (id)socket + errNo: (int)errNo OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated connect SPX socket failed exception. + * + * @param network The IPX network of the node to which the connection failed + * @param node The node to which the connection failed + * @param port The port on the node to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return An initialized connect SPX socket failed exception + */ +- (instancetype) + initWithNetwork: (uint32_t)network + node: (const unsigned char [_Nullable IPX_NODE_LEN])node + port: (uint16_t)port + socket: (id)socket + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; + +/** + * @brief Get the IPX node to which the connection failed. + * + * @param node A pointer to where to write the node to + */ +- (void)getNode: (unsigned char [_Nonnull IPX_NODE_LEN])node; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFConnectSPXSocketFailedException.m Index: src/exceptions/OFConnectSPXSocketFailedException.m ================================================================== --- src/exceptions/OFConnectSPXSocketFailedException.m +++ src/exceptions/OFConnectSPXSocketFailedException.m @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFConnectSPXSocketFailedException.h" +#import "OFData.h" +#import "OFString.h" + +@implementation OFConnectSPXSocketFailedException +@synthesize network = _network, port = _port; + ++ (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype)exceptionWithNetwork: (uint32_t)network + node: (const unsigned char [IPX_NODE_LEN])node + port: (uint16_t)port + socket: (id)sock + errNo: (int)errNo +{ + return [[[self alloc] initWithNetwork: network + node: node + port: port + socket: sock + errNo: errNo] autorelease]; +} + +- (instancetype)initWithSocket: (id)sock errNo: (int)errNo +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithNetwork: (uint32_t)network + node: (const unsigned char [IPX_NODE_LEN])node + port: (uint16_t)port + socket: (id)sock + errNo: (int)errNo +{ + self = [super initWithSocket: sock errNo: errNo]; + + @try { + _network = network; + memcpy(_node, node, IPX_NODE_LEN); + _port = port; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)getNode: (unsigned char [IPX_NODE_LEN])node +{ + memcpy(node, _node, sizeof(_node)); +} + +- (OFString *)description +{ + OFData *node = [OFData dataWithItems: _node count: sizeof(_node)]; + + return [OFString stringWithFormat: + @"A connection to %@ port %" @PRIu16 @" on network %" @PRIX32 + " could not be established in socket of type %@: %@", + node, _port, _network, [_socket class], OFStrError(_errNo)]; +} +@end ADDED src/exceptions/OFConnectSocketFailedException.h Index: src/exceptions/OFConnectSocketFailedException.h ================================================================== --- src/exceptions/OFConnectSocketFailedException.h +++ src/exceptions/OFConnectSocketFailedException.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFException.h" + +#ifndef OF_HAVE_SOCKETS +# error No sockets available! +#endif + +#import "OFSocket.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFConnectSocketFailedException \ + * OFConnectSocketFailedException.h \ + * ObjFW/OFConnectSocketFailedException.h + * + * @brief An exception indicating that a connection could not be established. + */ +@interface OFConnectSocketFailedException: OFException +{ + id _socket; + int _errNo; + OF_RESERVE_IVARS(OFConnectSocketFailedException, 4) +} + +/** + * @brief The socket which could not connect. + */ +@property (readonly, nonatomic) id socket; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased connect socket failed exception. + * + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return A new, autoreleased connect socket failed exception + */ ++ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated connect socket failed exception. + * + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return An initialized connect socket failed exception + */ +- (instancetype)initWithSocket: (id)socket + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFConnectSocketFailedException.m Index: src/exceptions/OFConnectSocketFailedException.m ================================================================== --- src/exceptions/OFConnectSocketFailedException.m +++ src/exceptions/OFConnectSocketFailedException.m @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectSocketFailedException.h" +#import "OFString.h" + +@implementation OFConnectSocketFailedException +@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: + @"A connection to could not be established in socket of type " + @"%@: %@", + [_socket class], OFStrError(_errNo)]; +} +@end ADDED src/exceptions/OFConnectUNIXSocketFailedException.h Index: src/exceptions/OFConnectUNIXSocketFailedException.h ================================================================== --- src/exceptions/OFConnectUNIXSocketFailedException.h +++ src/exceptions/OFConnectUNIXSocketFailedException.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectSocketFailedException.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFConnectUNIXSocketFailedException \ + * OFConnectUNIXSocketFailedException.h \ + * ObjFW/OFConnectUNIXSocketFailedException.h + * + * @brief An exception indicating that a UNIX socket connection could not be + * established. + */ +OF_SUBCLASSING_RESTRICTED +@interface OFConnectUNIXSocketFailedException: OFConnectSocketFailedException +{ + OFString *_Nullable _path; +} + +/** + * @brief The path to which the connection failed. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; + +/** + * @brief Creates a new, autoreleased connect UNIX socket failed exception. + * + * @param path The path to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return A new, autoreleased connect 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 connect UNIX socket failed exception. + * + * @param path The path to which the connection failed + * @param socket The socket which could not connect + * @param errNo The errno of the error that occurred + * @return An initialized connect 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/OFConnectUNIXSocketFailedException.m Index: src/exceptions/OFConnectUNIXSocketFailedException.m ================================================================== --- src/exceptions/OFConnectUNIXSocketFailedException.m +++ src/exceptions/OFConnectUNIXSocketFailedException.m @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFConnectUNIXSocketFailedException.h" +#import "OFString.h" + +@implementation OFConnectUNIXSocketFailedException +@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: + @"A connection to %@ could not be established in socket of type " + @"%@: %@", + _path, [_socket class], OFStrError(_errNo)]; +} +@end DELETED src/exceptions/OFConnectionFailedException.h Index: src/exceptions/OFConnectionFailedException.h ================================================================== --- src/exceptions/OFConnectionFailedException.h +++ src/exceptions/OFConnectionFailedException.h @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFException.h" - -#ifndef OF_HAVE_SOCKETS -# error No sockets available! -#endif - -#import "OFSocket.h" - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFConnectionFailedException \ - * OFConnectionFailedException.h ObjFW/OFConnectionFailedException.h - * - * @brief An exception indicating that a connection could not be established. - */ -@interface OFConnectionFailedException: OFException -{ - OFString *_Nullable _host; - uint16_t _port; - OFString *_Nullable _path; - uint32_t _network; - unsigned char _node[IPX_NODE_LEN]; - id _socket; - int _errNo; - OF_RESERVE_IVARS(OFConnectionFailedException, 4) -} - -/** - * @brief The host to which the connection failed. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *host; - -/** - * @brief The port on the host to which the connection failed. - */ -@property (readonly, nonatomic) uint16_t port; - -/** - * @brief The path to which the connection failed. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; - -/** - * @brief The IPX network of the node to which the connection failed. - */ -@property (readonly, nonatomic) uint32_t network; - -/** - * @brief The IPX node to which the connection failed. - */ -@property (readonly, nonatomic) unsigned char *node; - -/** - * @brief The socket which could not connect. - */ -@property (readonly, nonatomic) id socket; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased connection failed exception. - * - * @param host The host to which the connection failed - * @param port The port on the host to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return A new, autoreleased connection failed exception - */ -+ (instancetype)exceptionWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Creates a new, autoreleased connection failed exception. - * - * @param path The path to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return A new, autoreleased connection failed exception - */ -+ (instancetype)exceptionWithPath: (OFString *)path - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Creates a new, autoreleased connection failed exception. - * - * @param network The IPX network of the node to which the connection failed - * @param node The node to which the connection failed - * @param port The port on the node to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return A new, autoreleased connection failed exception - */ -+ (instancetype) - exceptionWithNetwork: (uint32_t)network - node: (unsigned char [_Nullable IPX_NODE_LEN])node - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated connection failed exception. - * - * @param host The host to which the connection failed - * @param port The port on the host to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return An initialized connection failed exception - */ -- (instancetype)initWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Initializes an already allocated connection failed exception. - * - * @param path The path to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return An initialized connection failed exception - */ -- (instancetype)initWithPath: (OFString *)path - socket: (id)socket - errNo: (int)errNo; - -/** - * @brief Initializes an already allocated connection failed exception. - * - * @param network The IPX network of the node to which the connection failed - * @param node The node to which the connection failed - * @param port The port on the node to which the connection failed - * @param socket The socket which could not connect - * @param errNo The errno of the error that occurred - * @return An initialized connection failed exception - */ -- (instancetype)initWithNetwork: (uint32_t)network - node: (unsigned char [_Nullable IPX_NODE_LEN])node - port: (uint16_t)port - socket: (id)socket - errNo: (int)errNo; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFConnectionFailedException.m Index: src/exceptions/OFConnectionFailedException.m ================================================================== --- src/exceptions/OFConnectionFailedException.m +++ src/exceptions/OFConnectionFailedException.m @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFConnectionFailedException.h" -#import "OFString.h" - -@implementation OFConnectionFailedException -@synthesize host = _host, port = _port, path = _path, network = _network; -@synthesize socket = _socket, errNo = _errNo; - -+ (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)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)exceptionWithPath: (OFString *)path - socket: (id)sock - errNo: (int)errNo -{ - return [[[self alloc] initWithPath: path - socket: sock - errNo: errNo] autorelease]; -} - -+ (instancetype)exceptionWithNetwork: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node - port: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - return [[[self alloc] initWithNetwork: network - node: node - port: port - socket: sock - errNo: errNo] autorelease]; -} - -- (instancetype)initWithHost: (OFString *)host - port: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _host = [host copy]; - _port = port; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (instancetype)initWithPath: (OFString *)path - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _path = [path copy]; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (instancetype)initWithNetwork: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node - port: (uint16_t)port - socket: (id)sock - errNo: (int)errNo -{ - self = [super init]; - - @try { - _network = network; - memcpy(_node, node, IPX_NODE_LEN); - _port = port; - _socket = [sock retain]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_host release]; - [_path release]; - [_socket release]; - - [super dealloc]; -} - -- (unsigned char *)node -{ - return _node; -} - -- (OFString *)description -{ - if (_path != nil) - return [OFString stringWithFormat: - @"A connection to %@ could not be established in socket of " - @"type %@: %@", - _path, [_socket class], OFStrError(_errNo)]; - else if (_host != nil) - return [OFString stringWithFormat: - @"A connection to %@ on port %" @PRIu16 @" could not be " - @"established in socket of type %@: %@", - _host, _port, [_socket class], OFStrError(_errNo)]; - else if (memcmp(_node, "\0\0\0\0\0", IPX_NODE_LEN) == 0) - return [OFString stringWithFormat: - @"A connection to %02X%02X%02X%02X%02X%02X port %" @PRIu16 - @" on network %" @PRIX32 " could not be established in " - @"socket of type %@: %@", - _node[0], _node[1], _node[2], _node[3], _node[4], _node[5], - _port, _network, [_socket class], OFStrError(_errNo)]; - else - return [OFString stringWithFormat: - @"A connection could not be established in socket of " - @"type %@: %@", - [_socket class], OFStrError(_errNo)]; -} -@end DELETED src/exceptions/OFListenFailedException.h Index: src/exceptions/OFListenFailedException.h ================================================================== --- src/exceptions/OFListenFailedException.h +++ src/exceptions/OFListenFailedException.h @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFException.h" - -#ifndef OF_HAVE_SOCKETS -# error No sockets available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFListenFailedException \ - * OFListenFailedException.h ObjFW/OFListenFailedException.h - * - * @brief An exception indicating that listening on the socket failed. - */ -@interface OFListenFailedException: OFException -{ - id _socket; - int _backlog, _errNo; - OF_RESERVE_IVARS(OFListenFailedException, 4) -} - -/** - * @brief The socket which failed to listen. - */ -@property (readonly, nonatomic) id socket; - -/** - * @brief The requested back log. - */ -@property (readonly, nonatomic) int backlog; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased listen failed exception. - * - * @param socket The socket which failed to listen - * @param backlog The requested size of the back log - * @param errNo The errno of the error that occurred - * @return A new, autoreleased listen failed exception - */ -+ (instancetype)exceptionWithSocket: (id)socket - backlog: (int)backlog - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated listen failed exception. - * - * @param socket The socket which failed to listen - * @param backlog The requested size of the back log - * @param errNo The errno of the error that occurred - * @return An initialized listen failed exception - */ -- (instancetype)initWithSocket: (id)socket - backlog: (int)backlog - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFListenFailedException.m Index: src/exceptions/OFListenFailedException.m ================================================================== --- src/exceptions/OFListenFailedException.m +++ src/exceptions/OFListenFailedException.m @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFListenFailedException.h" -#import "OFString.h" - -@implementation OFListenFailedException -@synthesize socket = _socket, backlog = _backlog, errNo = _errNo; - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)exceptionWithSocket: (id)socket - backlog: (int)backlog - errNo: (int)errNo -{ - return [[[self alloc] initWithSocket: socket - backlog: backlog - errNo: errNo] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithSocket: (id)socket - backlog: (int)backlog - errNo: (int)errNo -{ - self = [super init]; - - _socket = [socket retain]; - _backlog = backlog; - _errNo = errNo; - - return self; -} - -- (void)dealloc -{ - [_socket release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Failed to listen in socket of type %@ with a back log of %d: %@", - [_socket class], _backlog, OFStrError(_errNo)]; -} -@end ADDED src/exceptions/OFListenOnSocketFailedException.h Index: src/exceptions/OFListenOnSocketFailedException.h ================================================================== --- src/exceptions/OFListenOnSocketFailedException.h +++ src/exceptions/OFListenOnSocketFailedException.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFException.h" + +#ifndef OF_HAVE_SOCKETS +# error No sockets available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFListenOnSocketFailedException \ + * OFListenOnSocketFailedException.h \ + * ObjFW/OFListenOnSocketFailedException.h + * + * @brief An exception indicating that listening on the socket failed. + */ +@interface OFListenOnSocketFailedException: OFException +{ + id _socket; + int _backlog, _errNo; + OF_RESERVE_IVARS(OFListenOnSocketFailedException, 4) +} + +/** + * @brief The socket which failed to listen. + */ +@property (readonly, nonatomic) id socket; + +/** + * @brief The requested back log. + */ +@property (readonly, nonatomic) int backlog; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased listen failed exception. + * + * @param socket The socket which failed to listen + * @param backlog The requested size of the back log + * @param errNo The errno of the error that occurred + * @return A new, autoreleased listen failed exception + */ ++ (instancetype)exceptionWithSocket: (id)socket + backlog: (int)backlog + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated listen failed exception. + * + * @param socket The socket which failed to listen + * @param backlog The requested size of the back log + * @param errNo The errno of the error that occurred + * @return An initialized listen failed exception + */ +- (instancetype)initWithSocket: (id)socket + backlog: (int)backlog + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFListenOnSocketFailedException.m Index: src/exceptions/OFListenOnSocketFailedException.m ================================================================== --- src/exceptions/OFListenOnSocketFailedException.m +++ src/exceptions/OFListenOnSocketFailedException.m @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFListenOnSocketFailedException.h" +#import "OFString.h" + +@implementation OFListenOnSocketFailedException +@synthesize socket = _socket, backlog = _backlog, errNo = _errNo; + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype)exceptionWithSocket: (id)sock + backlog: (int)backlog + errNo: (int)errNo +{ + return [[[self alloc] initWithSocket: sock + backlog: backlog + errNo: errNo] autorelease]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithSocket: (id)sock backlog: (int)backlog errNo: (int)errNo +{ + self = [super init]; + + _socket = [sock retain]; + _backlog = backlog; + _errNo = errNo; + + return self; +} + +- (void)dealloc +{ + [_socket release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Failed to listen in socket of type %@ with a back log of %d: %@", + [_socket class], _backlog, OFStrError(_errNo)]; +} +@end Index: tests/OFDDPSocketTests.m ================================================================== --- tests/OFDDPSocketTests.m +++ tests/OFDDPSocketTests.m @@ -31,11 +31,11 @@ TEST(@"+[socket]", (sock = [OFDDPSocket socket])) @try { TEST(@"-[bindToPort:]", R(address1 = [sock bindToPort: 0])) - } @catch (OFBindFailedException *e) { + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: @"\r[OFDDPSocket] -[bindToPort:] " Index: tests/OFIPXSocketTests.m ================================================================== --- tests/OFIPXSocketTests.m +++ tests/OFIPXSocketTests.m @@ -22,33 +22,38 @@ static OFString *const module = @"OFIPXSocket"; @implementation TestsAppDelegate (OFIPXSocketTests) - (void)IPXSocketTests { + const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; void *pool = objc_autoreleasePoolPush(); OFIPXSocket *sock; OFSocketAddress address1, address2; char buffer[5]; TEST(@"+[socket]", (sock = [OFIPXSocket socket])) @try { - TEST(@"-[bindToPort:packetType:]", - R(address1 = [sock bindToPort: 0 packetType: 0])) - } @catch (OFBindFailedException *e) { + TEST(@"-[bindToNetwork:node:port:packetType:]", + R(address1 = [sock bindToNetwork: 0 + node: zeroNode + port: 0 + packetType: 0])) + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFIPXSocket] -[bindToPort:packetType:]: " - @"IPX unsupported, skipping tests"]; + @"\r[OFIPXSocket] -[bindToNetwork:node:port:" + @"packetType:]: IPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFIPXSocket] -[bindToPort:packetType:]: " - @"IPX not configured, skipping tests"]; + @"\r[OFIPXSocket] -[bindToNetwork:node:port:" + @"packetType:]: IPX not configured, skipping " + @"tests"]; break; default: @throw e; } Index: tests/OFSPXSocketTests.m ================================================================== --- tests/OFSPXSocketTests.m +++ tests/OFSPXSocketTests.m @@ -50,11 +50,11 @@ return false; } - (void)socket: (OFSPXSocket *)sock didConnectToNetwork: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port exception: (id)exception { OFEnsure(!_connected); @@ -69,10 +69,11 @@ @end @implementation TestsAppDelegate (OFSPXSocketTests) - (void)SPXSocketTests { + const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; void *pool = objc_autoreleasePoolPush(); OFSPXSocket *sockClient, *sockServer = nil, *sockAccepted; OFSocketAddress address1; const OFSocketAddress *address2; uint32_t network; @@ -83,30 +84,32 @@ TEST(@"+[socket]", (sockClient = [OFSPXSocket socket]) && (sockServer = [OFSPXSocket socket])) @try { - TEST(@"-[bindToPort:]", - R(address1 = [sockServer bindToPort: 0])) - } @catch (OFBindFailedException *e) { + TEST(@"-[bindToNetwork:node:port:]", + R(address1 = [sockServer bindToNetwork: 0 + node: zeroNode + port: 0])) + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToNetwork:node:port:]: " @"IPX unsupported, skipping tests"]; break; case ESOCKTNOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToNetwork:node:port:]: " @"SPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToNetwork:node:port:]: " @"IPX not configured, skipping tests"]; break; default: @throw e; } @@ -114,11 +117,11 @@ objc_autoreleasePoolPop(pool); return; } network = OFSocketAddressIPXNetwork(&address1); - OFSocketAddressIPXNode(&address1, node); + OFSocketAddressGetIPXNode(&address1, node); port = OFSocketAddressPort(&address1); TEST(@"-[listen]", R([sockServer listen])) TEST(@"-[connectToNetwork:node:port:]", @@ -134,11 +137,11 @@ memcmp(buffer, "Hello", 5) == 0) TEST(@"-[remoteAddress]", (address2 = sockAccepted.remoteAddress) && OFSocketAddressIPXNetwork(address2) == network && - R(OFSocketAddressIPXNode(address2, node2)) && + R(OFSocketAddressGetIPXNode(address2, node2)) && memcmp(node, node2, IPX_NODE_LEN) == 0) delegate = [[[SPXSocketDelegate alloc] init] autorelease]; sockServer = [OFSPXSocket socket]; @@ -147,17 +150,17 @@ sockClient = [OFSPXSocket socket]; delegate->_expectedClientSocket = sockClient; sockClient.delegate = delegate; - address1 = [sockServer bindToPort: 0]; + address1 = [sockServer bindToNetwork: 0 node: zeroNode port: 0]; [sockServer listen]; [sockServer asyncAccept]; delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&address1); - OFSocketAddressIPXNode(&address1, node); + OFSocketAddressGetIPXNode(&address1, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedPort = port = OFSocketAddressPort(&address1); @try { [sockClient asyncConnectToNetwork: network Index: tests/OFSPXStreamSocketTests.m ================================================================== --- tests/OFSPXStreamSocketTests.m +++ tests/OFSPXStreamSocketTests.m @@ -50,11 +50,11 @@ return false; } - (void)socket: (OFSPXStreamSocket *)sock didConnectToNetwork: (uint32_t)network - node: (unsigned char [IPX_NODE_LEN])node + node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port exception: (id)exception { OFEnsure(!_connected); @@ -69,10 +69,11 @@ @end @implementation TestsAppDelegate (OFSPXStreamSocketTests) - (void)SPXStreamSocketTests { + const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; void *pool = objc_autoreleasePoolPush(); OFSPXStreamSocket *sockClient, *sockServer = nil, *sockAccepted; OFSocketAddress address1; const OFSocketAddress *address2; uint32_t network; @@ -83,32 +84,34 @@ TEST(@"+[socket]", (sockClient = [OFSPXStreamSocket socket]) && (sockServer = [OFSPXStreamSocket socket])) @try { - TEST(@"-[bindToPort:]", - R(address1 = [sockServer bindToPort: 0])) - } @catch (OFBindFailedException *e) { + TEST(@"-[bindToNetwork:node:port:]", + R(address1 = [sockServer bindToNetwork: 0 + node: zeroNode + port: 0])) + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXStreamSocket] -[bindToPort:]: " - @"IPX unsupported, skipping tests"]; + @"\r[OFSPXStreamSocket] -[bindToNetwork:node:" + @"port:]: IPX unsupported, skipping tests"]; break; case ESOCKTNOSUPPORT: case EPROTONOSUPPORT: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXStreamSocket] -[bindToPort:]: " - @"SPX unsupported, skipping tests"]; + @"\r[OFSPXStreamSocket] -[bindToNetwork:node:" + @"port:]: SPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: - @"\r[OFSPXStreamSocket] -[bindToPort:]: " - @"IPX not configured, skipping tests"]; + @"\r[OFSPXStreamSocket] -[bindToNetwork:node:" + @"port:]: IPX not configured, skipping tests"]; break; default: @throw e; } @@ -115,11 +118,11 @@ objc_autoreleasePoolPop(pool); return; } network = OFSocketAddressIPXNetwork(&address1); - OFSocketAddressIPXNode(&address1, node); + OFSocketAddressGetIPXNode(&address1, node); port = OFSocketAddressPort(&address1); TEST(@"-[listen]", R([sockServer listen])) TEST(@"-[connectToNetwork:node:port:]", @@ -138,11 +141,11 @@ memcmp(buffer, "llo", 3) == 0) TEST(@"-[remoteAddress]", (address2 = sockAccepted.remoteAddress) && OFSocketAddressIPXNetwork(address2) == network && - R(OFSocketAddressIPXNode(address2, node2)) && + R(OFSocketAddressGetIPXNode(address2, node2)) && memcmp(node, node2, IPX_NODE_LEN) == 0) delegate = [[[SPXStreamSocketDelegate alloc] init] autorelease]; sockServer = [OFSPXStreamSocket socket]; @@ -151,17 +154,17 @@ sockClient = [OFSPXStreamSocket socket]; delegate->_expectedClientSocket = sockClient; sockClient.delegate = delegate; - address1 = [sockServer bindToPort: 0]; + address1 = [sockServer bindToNetwork: 0 node: zeroNode port: 0]; [sockServer listen]; [sockServer asyncAccept]; delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&address1); - OFSocketAddressIPXNode(&address1, node); + OFSocketAddressGetIPXNode(&address1, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedPort = port = OFSocketAddressPort(&address1); @try { [sockClient asyncConnectToNetwork: network Index: tests/OFUNIXDatagramSocketTests.m ================================================================== --- tests/OFUNIXDatagramSocketTests.m +++ tests/OFUNIXDatagramSocketTests.m @@ -48,11 +48,11 @@ TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket])) @try { TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path])) - } @catch (OFBindFailedException *e) { + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: case EPERM: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: Index: tests/OFUNIXStreamSocketTests.m ================================================================== --- tests/OFUNIXStreamSocketTests.m +++ tests/OFUNIXStreamSocketTests.m @@ -48,11 +48,11 @@ TEST(@"+[socket]", (sockClient = [OFUNIXStreamSocket socket]) && (sockServer = [OFUNIXStreamSocket socket])) @try { TEST(@"-[bindToPath:]", R([sockServer bindToPath: path])) - } @catch (OFBindFailedException *e) { + } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: case EPERM: [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeLine: Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -38,11 +38,11 @@ #ifdef HAVE_TLS_SUPPORT # import "ObjFWTLS.h" #endif -#import "OFConnectionFailedException.h" +#import "OFConnectSocketFailedException.h" #import "OFGetItemAttributesFailedException.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerResponseException.h" @@ -821,11 +821,11 @@ @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], @"uri", request.URI.string, @"exception", exception)]; } else if ([exception isKindOfClass: - [OFConnectionFailedException class]]) { + [OFConnectSocketFailedException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED(@"download_failed_connection_failed",