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.
This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-30 11:20:22 +02:00
parent a16e7c468c
commit 16a17a496c

View file

@ -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 )