Microsoft Windows CE 3.0  

getsockname

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This function gets the local address for a socket.

int
getsockname
(
SOCKET
s
,
struct
sockaddr
*
name
,
int
*
namelen
);

Parameters

s
[in] Descriptor that identifies a bound socket.
name
[out] Receives the socket address (name).
namelen
[in/out] namebuffer size.

Return Values

Zero indicates no error occurred. SOCKET_ERROR indicates failure. To get a specific error value, call WSAGetLastError.

Remarks

The getsocknamefunction retrieves the current name for the specified socket descriptor in name. It is used on the bound or connected socket specified by the sparameter. The local association is returned. This call is especially useful when a connectcall has been made without doing a bindfirst; the getsocknamefunction provides the only way to determine the local association set by the system.

On call, the namelenargument contains the namebuffer size, in bytes. On return, the namelenparameter contains the actual nameparameter size, in bytes.

The getsocknamefunction does not always return data about the host address when the socket has been bound to an unspecified address, unless the socket has been connected with connector accept(for example, using ADDR_ANY). A Windows Sockets application must not assume that the address will be specified unless the socket is connected. The address used for the socket is unknown unless the socket is connected when used in a multihomed host. If the socket is using a connectionless protocol, the address may not be available until I/O occurs on the socket.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winsock.h    
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

accept, bind, connect, getpeername, socket, WSAStartup