CAsyncSocket::Connect BOOL Connect( LPCTSTR lpszHostAddress, UINT nHostPort ); BOOL Connect( const SOCKADDR* lpSockAddr, int nSockAddrLen );Return Value: Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError. If this indicates an error code of WSAEWOULDBLOCK, and your application is using the overridable callbacks, your application will receive an OnConnect message when the connect operation is complete. The following errors apply to this member function: WSANOTINITIALISED A successful AfxSocketInit must occur before using this API. WSAENETDOWN The Windows Sockets implementation detected that the network subsystem failed. WSAEADDRINUSE The specified address is already in use. WSAEINPROGRESS A blocking Windows Sockets call is in progress. WSAEADDRNOTAVAIL The specified address is not available from the local machine. WSAEAFNOSUPPORT Addresses in the specified family cannot be used with this socket. WSAECONNREFUSED The attempt to connect was rejected. WSAEDESTADDRREQ A destination address is required. WSAEFAULT The nSockAddrLen argument is incorrect. WSAEINVAL Invalid host address. WSAEISCONN The socket is already connected. WSAEMFILE No more file descriptors are available. WSAENETUNREACH The network cannot be reached from this host at this time. WSAENOBUFS No buffer space is available. The socket cannot be connected. WSAENOTSOCK The descriptor is not a socket. WSAETIMEDOUT Attempt to connect timed out without establishing a connection. WSAEWOULDBLOCK The socket is ed as nonblocking and the connection cannot be completed immediately.
BOOL Connect(
LPCTSTR lpszHostAddress,
UINT nHostPort
);
BOOL Connect(
const SOCKADDR* lpSockAddr,
int nSockAddrLen
);Return Value:
Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError. If this indicates an error code of WSAEWOULDBLOCK, and your application is using the overridable callbacks, your application will receive an OnConnect message when the connect operation is complete. The following errors apply to this member function: WSANOTINITIALISED A successful AfxSocketInit must occur before using this API. WSAENETDOWN The Windows Sockets implementation detected that the network subsystem failed. WSAEADDRINUSE The specified address is already in use. WSAEINPROGRESS A blocking Windows Sockets call is in progress. WSAEADDRNOTAVAIL The specified address is not available from the local machine. WSAEAFNOSUPPORT Addresses in the specified family cannot be used with this socket. WSAECONNREFUSED The attempt to connect was rejected. WSAEDESTADDRREQ A destination address is required. WSAEFAULT The nSockAddrLen argument is incorrect. WSAEINVAL Invalid host address. WSAEISCONN The socket is already connected. WSAEMFILE No more file descriptors are available. WSAENETUNREACH The network cannot be reached from this host at this time. WSAENOBUFS No buffer space is available. The socket cannot be connected. WSAENOTSOCK The descriptor is not a socket. WSAETIMEDOUT Attempt to connect timed out without establishing a connection. WSAEWOULDBLOCK The socket is ed as nonblocking and the connection cannot be completed immediately.