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;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* 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)
|
||||
static int do_connect(int fd, const struct WS_sockaddr* name, int namelen)
|
||||
{
|
||||
union generic_unix_sockaddr uaddr;
|
||||
unsigned int uaddrlen = ws_sockaddr_ws2u(name, namelen, &uaddr);
|
||||
|
||||
if (!uaddrlen)
|
||||
{
|
||||
SetLastError(WSAEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return WSAEFAULT;
|
||||
|
||||
if (name->sa_family == WS_AF_INET)
|
||||
{
|
||||
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)
|
||||
goto connect_success;
|
||||
return 0;
|
||||
|
||||
return wsaErrno();
|
||||
}
|
||||
|
||||
if (errno == EINPROGRESS)
|
||||
/***********************************************************************
|
||||
* 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 */
|
||||
_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
|
||||
{
|
||||
SetLastError(wsaErrno());
|
||||
SetLastError(ret);
|
||||
}
|
||||
release_sock_fd( s, fd );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue