[PATCH 2/6] webservices: Try to receive the whole message at once.
Jacek Caban
jacek at codeweavers.com
Wed Oct 31 10:06:08 CDT 2018
Hi Hans,
On 10/31/2018 02:21 PM, Hans Leidekker wrote:
> +static void set_blocking( SOCKET socket, BOOL blocking )
> +{
> + ULONG state = !blocking;
> + ioctlsocket( socket, FIONBIO, &state );
> +}
> +
> +static int sock_peek( SOCKET socket )
> +{
> + int ret;
> + char byte;
> +
> + set_blocking( socket, FALSE );
> + ret = recv( socket, &byte, 1, MSG_PEEK );
> + set_blocking( socket, TRUE );
> + return ret;
> +}
> +
> +static int sock_recv( SOCKET socket, char *buf, int len )
> +{
> + int count, ret = 0;
> + for (;;)
> + {
> + if ((count = recv( socket, buf + ret, len, 0 )) <= 0) break;
> + ret += count;
> + len -= count;
> + if (sock_peek( socket ) != 1) break;
It seems to me that you don't really need sock_peek. You could just set
socket to non-blocking mode after the first successful recv.
Jacek
More information about the wine-devel
mailing list