getsockname

getsockname fills in the IP address and port that we are using on a specified socket.

Syntax

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

Parameters

s

A socket descriptor.

name

A pointer to a socket address structure that will be filled in by getsockname.

namelen

A pointer to an integer that defines the size of the socket address structure indicated by name. Upon return, namelen shall contain the actual size in bytes of name.

Return Value

If the function succeeds, it returns 0 (zero). If the function fails, it returns SOCKET_ERROR.

Use WSAGetLastError to retrieve a specific error code.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Winsock2.h RtTcpipApi.lib