ws2_32: Create a wrapper for connect.
This commit is contained in:
parent
fae0b6fa63
commit
15cc301728
|
@ -1803,26 +1803,14 @@ int WINAPI WS_closesocket(SOCKET s)
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
static int do_connect(int fd, const struct WS_sockaddr* name, int namelen)
|
||||||
* connect (WS2_32.4)
|
|
||||||
*/
|
|
||||||
int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen)
|
|
||||||
{
|
{
|
||||||
int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
|
|
||||||
|
|
||||||
TRACE("socket %04lx, ptr %p %s, length %d\n", s, name, debugstr_sockaddr(name), namelen);
|
|
||||||
|
|
||||||
if (fd != -1)
|
|
||||||
{
|
|
||||||
union generic_unix_sockaddr uaddr;
|
union generic_unix_sockaddr uaddr;
|
||||||
unsigned int uaddrlen = ws_sockaddr_ws2u(name, namelen, &uaddr);
|
unsigned int uaddrlen = ws_sockaddr_ws2u(name, namelen, &uaddr);
|
||||||
|
|
||||||
if (!uaddrlen)
|
if (!uaddrlen)
|
||||||
{
|
return WSAEFAULT;
|
||||||
SetLastError(WSAEFAULT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (name->sa_family == WS_AF_INET)
|
if (name->sa_family == WS_AF_INET)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *in4 = (struct sockaddr_in*) &uaddr;
|
struct sockaddr_in *in4 = (struct sockaddr_in*) &uaddr;
|
||||||
|
@ -1837,10 +1825,27 @@ int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(fd, &uaddr.addr, uaddrlen) == 0)
|
if (connect(fd, &uaddr.addr, uaddrlen) == 0)
|
||||||
goto connect_success;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == EINPROGRESS)
|
return wsaErrno();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* connect (WS2_32.4)
|
||||||
|
*/
|
||||||
|
int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen)
|
||||||
|
{
|
||||||
|
int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
|
||||||
|
|
||||||
|
TRACE("socket %04lx, ptr %p %s, length %d\n", s, name, debugstr_sockaddr(name), namelen);
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
{
|
||||||
|
int ret = do_connect(fd, name, namelen);
|
||||||
|
if (ret == 0)
|
||||||
|
goto connect_success;
|
||||||
|
|
||||||
|
if (ret == WSAEINPROGRESS)
|
||||||
{
|
{
|
||||||
/* tell wineserver that a connection is in progress */
|
/* tell wineserver that a connection is in progress */
|
||||||
_enable_event(SOCKET2HANDLE(s), FD_CONNECT|FD_READ|FD_WRITE,
|
_enable_event(SOCKET2HANDLE(s), FD_CONNECT|FD_READ|FD_WRITE,
|
||||||
|
@ -1868,7 +1873,7 @@ int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetLastError(wsaErrno());
|
SetLastError(ret);
|
||||||
}
|
}
|
||||||
release_sock_fd( s, fd );
|
release_sock_fd( s, fd );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue