diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index a03be0c65fc..76e49dabdc4 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -299,12 +299,13 @@ void netconn_unload( void ) #endif } -netconn_t *netconn_create( int domain, int type, int protocol ) +netconn_t *netconn_create( const struct sockaddr_storage *sockaddr ) { netconn_t *conn; conn = heap_alloc_zero(sizeof(*conn)); if (!conn) return NULL; - if ((conn->socket = socket( domain, type, protocol )) == -1) + conn->sockaddr = *sockaddr; + if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1) { WARN("unable to create socket (%s)\n", strerror(errno)); set_last_error( sock_get_error( errno ) ); @@ -335,14 +336,14 @@ BOOL netconn_close( netconn_t *conn ) return TRUE; } -BOOL netconn_connect( netconn_t *conn, const struct sockaddr_storage *sockaddr, int timeout ) +BOOL netconn_connect( netconn_t *conn, int timeout ) { unsigned int addr_len; BOOL ret = FALSE; int res; ULONG state; - switch (sockaddr->ss_family) + switch (conn->sockaddr.ss_family) { case AF_INET: addr_len = sizeof(struct sockaddr_in); @@ -363,7 +364,7 @@ BOOL netconn_connect( netconn_t *conn, const struct sockaddr_storage *sockaddr, for (;;) { res = 0; - if (connect( conn->socket, (const struct sockaddr *)sockaddr, addr_len ) < 0) + if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0) { res = sock_get_error( errno ); if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index ce4e39c46cf..50769354573 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1021,14 +1021,14 @@ static BOOL open_connection( request_t *request ) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); - if (!(netconn = netconn_create( connect->sockaddr.ss_family, SOCK_STREAM, 0 ))) + if (!(netconn = netconn_create( &connect->sockaddr ))) { heap_free( addressW ); return FALSE; } netconn_set_timeout( netconn, TRUE, request->send_timeout ); netconn_set_timeout( netconn, FALSE, request->recv_timeout ); - if (!netconn_connect( netconn, &connect->sockaddr, request->connect_timeout )) + if (!netconn_connect( netconn, request->connect_timeout )) { netconn_close( netconn ); heap_free( addressW ); diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index d5cf3d59333..480311bd3b3 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -130,6 +130,7 @@ typedef struct typedef struct { int socket; + struct sockaddr_storage sockaddr; BOOL secure; /* SSL active on connection? */ CtxtHandle ssl_ctx; SecPkgContext_StreamSizes ssl_sizes; @@ -282,8 +283,8 @@ void send_callback( object_header_t *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN; void close_connection( request_t * ) DECLSPEC_HIDDEN; BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN; -BOOL netconn_connect( netconn_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; -netconn_t *netconn_create( int, int, int ) DECLSPEC_HIDDEN; +BOOL netconn_connect( netconn_t *, int ) DECLSPEC_HIDDEN; +netconn_t *netconn_create( const struct sockaddr_storage * ) DECLSPEC_HIDDEN; void netconn_unload( void ) DECLSPEC_HIDDEN; ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN; BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;