get_sockname()

get_sockname()#

get_sockname() retrieves the local socket address associated with the given file descriptor and stores it as a string.

Prototype

int get_sockname(
    char *bf,
    size_t bfsize,
    int fd
);

Parameters

Key

Type

Description

bf

char *

Buffer to store the local socket address as a string.

bfsize

size_t

Size of the buffer bf to prevent overflow.

fd

int

File descriptor of the socket whose local address is to be retrieved.


Return Value

Returns 0 on success, or -1 on failure.

Notes

This function is useful for obtaining the local address of a socket, particularly in network applications.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples