Fix net_accept() for UDP sockets on Windows

On Windows, recvfrom() returns an error code if the destination buffer is too
small to hold the next datagram.
parent a16e7c46
......@@ -309,6 +309,15 @@ int mbedtls_net_accept( int bind_fd, int *client_fd,
ret = recvfrom( bind_fd, buf, sizeof( buf ), MSG_PEEK,
(struct sockaddr *) &client_addr, &n );
#if defined(_WIN32)
if( ret == SOCKET_ERROR &&
WSAGetLastError() == WSAEMSGSIZE )
{
/* We know buf is too small, thanks, just peeking here */
ret = 0;
}
#endif
}
if( ret < 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment