Overview
Comment: | OFDatagramSocket: Make sender nullable |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6ed8be900e842bd173a087d302f4b658 |
User & Date: | js on 2022-11-06 20:31:24 |
Other Links: | manifest | tags |
Context
2022-11-06
| ||
20:36 | Rename OFIPSocketAsyncConnector check-in: 24ff63b586 user: js tags: trunk | |
20:31 | OFDatagramSocket: Make sender nullable check-in: 6ed8be900e user: js tags: trunk | |
20:20 | OFDNSResolverSettings: Use native encoding check-in: 0ceb5bb869 user: js tags: trunk | |
Changes
Modified src/OFDDPSocket.m from [11bd6fb256] to [f84809166c].
︙ | ︙ | |||
192 193 194 195 196 197 198 | ssize_t ret; uint8_t protocolType; struct iovec iov[2] = { { &protocolType, 1 }, { buffer, length } }; struct msghdr msg = { | > | > | > | | > | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | ssize_t ret; uint8_t protocolType; struct iovec iov[2] = { { &protocolType, 1 }, { buffer, length } }; struct msghdr msg = { .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) @throw [OFNotOpenException exceptionWithObject: self]; if ((ret = recvmsg(_socket, &msg, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: OFSocketErrNo()]; if (ret < 1 || protocolType != _protocolType) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOMSG]; if (sender != NULL) { sender->length = msg.msg_namelen; sender->family = OFSocketAddressFamilyAppleTalk; } return ret - 1; } - (void)sendBuffer: (const void *)buffer length: (size_t)length receiver: (const OFSocketAddress *)receiver |
︙ | ︙ |
Modified src/OFDNSResolver.m from [982d647b8f] to [9048cbfc52].
︙ | ︙ | |||
906 907 908 909 910 911 912 | if (context == nil) return true; if (context->_TCPSocket != nil) { if ([_TCPQueries objectForKey: context->_TCPSocket] != context) return true; | > | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | if (context == nil) return true; if (context->_TCPSocket != nil) { if ([_TCPQueries objectForKey: context->_TCPSocket] != context) return true; } else if (sender == NULL || !OFSocketAddressEqual(sender, &context->_usedNameServer)) return true; [context->_cancelTimer invalidate]; [context->_cancelTimer release]; context->_cancelTimer = nil; [_queries removeObjectForKey: ID]; |
︙ | ︙ |
Modified src/OFDatagramSocket.h from [777d90d4d3] to [81b28eb069].
︙ | ︙ | |||
156 157 158 159 160 161 162 | * address of the sender * @return The length of the received datagram * @throw OFReadFailedException Receiving failed * @throw OFNotOpenException The socket is not open */ - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | * address of the sender * @return The length of the received datagram * @throw OFReadFailedException Receiving failed * @throw OFNotOpenException The socket is not open */ - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length sender: (nullable OFSocketAddress *)sender; /** * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * |
︙ | ︙ |
Modified src/OFDatagramSocket.m from [946605e073] to [ea19c6b109].
︙ | ︙ | |||
169 170 171 172 173 174 175 | sender: (OFSocketAddress *)sender { ssize_t ret; if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; | > | | > | > > | | | | | | | | | | | | | | | | | | | > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | sender: (OFSocketAddress *)sender { ssize_t ret; if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (sender != NULL) sender->length = (socklen_t)sizeof(sender->sockaddr); #ifndef OF_WINDOWS if ((ret = recvfrom(_socket, buffer, length, 0, (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL), (sender != NULL ? &sender->length : NULL))) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: OFSocketErrNo()]; #else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = recvfrom(_socket, buffer, (int)length, 0, (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL), (sender != NULL ? &sender->length : NULL))) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: OFSocketErrNo()]; #endif if (sender != NULL) { switch (((struct sockaddr *)&sender->sockaddr)->sa_family) { case AF_INET: sender->family = OFSocketAddressFamilyIPv4; break; #ifdef OF_HAVE_IPV6 case AF_INET6: sender->family = OFSocketAddressFamilyIPv6; break; #endif #ifdef OF_HAVE_UNIX_SOCKETS case AF_UNIX: sender->family = OFSocketAddressFamilyUNIX; break; #endif #ifdef OF_HAVE_IPX case AF_IPX: sender->family = OFSocketAddressFamilyIPX; break; #endif #ifdef OF_HAVE_APPLETALK case AF_APPLETALK: sender->family = OFSocketAddressFamilyAppleTalk; break; #endif default: sender->family = OFSocketAddressFamilyUnknown; break; } } return ret; } - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length { |
︙ | ︙ |