@@ -44,14 +44,10 @@ unsigned short netStart, netEnd; at_nvestr_t zoneName; }; #endif -#ifndef ATPROTO_BASE -# define ATPROTO_BASE 0 -#endif - @implementation OFDDPSocket @dynamic delegate; - (OFSocketAddress)bindToNetwork: (uint16_t)network node: (uint8_t)node @@ -73,17 +69,20 @@ if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeAppleTalk(network, node, port); -#ifdef OF_MACOS +#if defined(OF_MACOS) if ((_socket = socket(address.sockaddr.at.sat_family, SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle) -#else +#elif defined(OF_WINDOWS) if ((_socket = socket(address.sockaddr.at.sat_family, SOCK_DGRAM | SOCK_CLOEXEC, ATPROTO_BASE + protocolType)) == OFInvalidSocketHandle) +#else + if ((_socket = socket(address.sockaddr.at.sat_family, + SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) #endif @throw [OFBindDDPSocketFailedException exceptionWithNetwork: network node: node port: port @@ -194,12 +193,14 @@ struct iovec iov[2] = { { &protocolType, 1 }, { buffer, length } }; struct msghdr msg = { - .msg_name = (struct sockaddr *)&sender->sockaddr, - .msg_namelen = (socklen_t)sizeof(sender->sockaddr), + .msg_name = (sender != NULL + ? (struct sockaddr *)&sender->sockaddr : NULL), + .msg_namelen = (sender != NULL + ? (socklen_t)sizeof(sender->sockaddr) : 0), .msg_iov = iov, .msg_iovlen = 2 }; if (_socket == OFInvalidSocketHandle) @@ -214,12 +215,14 @@ if (ret < 1 || protocolType != _protocolType) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOMSG]; - sender->length = msg.msg_namelen; - sender->family = OFSocketAddressFamilyAppleTalk; + if (sender != NULL) { + sender->length = msg.msg_namelen; + sender->family = OFSocketAddressFamilyAppleTalk; + } return ret - 1; } - (void)sendBuffer: (const void *)buffer