CAsyncSocket::GetSockNameEx
Call this member function to get the local name for a socket (handles IPv6 addresses).
BOOL GetSockNameEx( CString& rSocketAddress, UINT& rSocketPort );
Parameters
- rSocketAddress
-
Reference to a CString object that receives a dotted number IP address.
- rSocketPort
-
Reference to a UINT that stores a port.
Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError. 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.
-
WSAEFAULT The lpSockAddrLen argument is not large enough.
-
WSAEINPROGRESS A blocking Windows Sockets operation is in progress.
-
WSAENOTSOCK The descriptor is not a socket.
-
WSAEINVAL The socket has not been bound to an address with Bind.
This call is the same as CAsyncSocket::GetSockName except that it handles IPv6 addresses as well as older protocols.
This call is especially useful when a Connect call has been made without doing a Bind first; this call provides the only means by which you can determine the local association which has been set by the system.