Juan Lang <juan.lang(a)gmail.com> writes:
> -BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len )
> +BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len, int timeout )
> {
> - if (connect( conn->socket, sockaddr, addr_len ) == -1)
> + int res, state;
> +
> + if (timeout > 0)
> + {
> + state = 1;
> + res = ioctlsocket( conn->socket, FIONBIO, &state );
> + }
> + res = connect( conn->socket, sockaddr, addr_len );
> + if (res == -1 && (errno == EINPROGRESS || errno == EAGAIN))
> + {
> + struct pollfd pfd;
> +
> + pfd.fd = conn->socket;
> + pfd.events = POLLOUT;
> + res = poll( &pfd, 1, timeout );
> + }
You also need to replace the errno check with the equivalent winsock
errors, and you need to correctly check the result of the poll.
--
Alexandre Julliard
julliard(a)winehq.org