@@ -29,23 +29,25 @@ #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; @@ -52,14 +54,16 @@ #endif if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: packetType - socket: self - errNo: OFSocketErrNo()]; + 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) @@ -72,14 +76,16 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: packetType - socket: self - errNo: errNo]; + 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); @@ -90,25 +96,29 @@ closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: packetType - socket: self - errNo: errNo]; + 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 [OFBindIPXSocketFailedException - exceptionWithPort: port - packetType: packetType - socket: self - errNo: EAFNOSUPPORT]; + exceptionWithNetwork: network + node: node + port: port + packetType: packetType + socket: self + errNo: EAFNOSUPPORT]; } return address; }