getsockname Function
C
int getsockname(
SOCKET s,
struct sockaddr * addr,
int * addrlen
);
Description
The function returns the current address to which the socket is bound, in the buffer pointed to by addr.
Preconditions
The socket() function should be called.
Parameters
Parameters | Description |
---|---|
s | Socket descriptor returned from a previous call to socket. |
addr | Address to store the current address to which the socket is bound. |
addrlen | On input it should point to the space (bytes) available in addr. On output, it points to the actual space required for storing the bound address. |
Returns
0 - If function is successful. The data is updated accordingly.
-1 - Error. errno is set appropriately.
Remarks
This function supports IPv4 connections only.