@@ -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 { @@ -222,11 +222,11 @@ 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; @@ -249,21 +249,21 @@ 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 [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: OFSocketErrNo()]; + 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,16 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + 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); @@ -366,25 +371,29 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: errNo]; + 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 [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: SPXPacketType - socket: self - errNo: EAFNOSUPPORT]; + exceptionWithNetwork: network + node: node + port: port + packetType: SPXPacketType + socket: self + errNo: EAFNOSUPPORT]; } return address; } @end