LPWSPGETSOCKNAME callback function (ws2spi.h)
The LPWSPGetSockName function gets the local name for a socket.
Syntax
LPWSPGETSOCKNAME Lpwspgetsockname;
int Lpwspgetsockname(
[in] SOCKET s,
[out] sockaddr *name,
[in, out] LPINT namelen,
[out] LPINT lpErrno
)
{...}
Parameters
[in] s
Descriptor identifying a bound socket.
[out] name
Pointer to a sockaddr structure used to supply the address (name) of the socket.
[in, out] namelen
On input, pointer to an integer that indicates the size of the structure pointed to by name, in bytes. On output indicates the size of the returned name, in bytes.
[out] lpErrno
Pointer to the error code.
Return value
If no error occurs, LPWSPGetSockName returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code is available in lpErrno.
Error Code | Meaning |
---|---|
The network subsystem has failed. | |
The name or the namelen parameter is not a valid part of the user address space, or the namelen parameter is too small. | |
Function is invoked when a callback is in progress. | |
The descriptor is not a socket. | |
Socket has not been bound to an address with LPWSPBind, or ADDR_ANY is specified in **LPWSPBind** but connection has not yet occurred. |
Remarks
LPWSPGetSockName retrieves the current name for the specified socket descriptor in name. It is used on a bound and/or connected socket specified by the s parameter. The local association is returned. This call is especially useful when a LPWSPConnect call has been made without doing a LPWSPBind first; as this call provides the only means by which the local association that has been set by the service provider can be determined.
If a socket was bound to an unspecified address (for example, ADDR_ANY), indicating that any of the host's addresses within the specified address family should be used for the socket, LPWSPGetSockName will not necessarily return information about the host address, unless the socket has been connected with LPWSPConnect or LPWSPAccept. The Windows Sockets SPI client must not assume that an address will be specified unless the socket is connected. This is because for a multihomed host, the address that will be used for the socket is unknown until the socket is connected.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Header | ws2spi.h |