get_peername()

get_peername()#

get_peername() retrieves the peer’s address and stores it in the provided buffer.

Prototype

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

Parameters

Key

Type

Description

bf

char *

Buffer to store the peer’s address.

bfsize

size_t

Size of the buffer to ensure safe storage.

fd

int

File descriptor of the socket whose peer address is retrieved.


Return Value

Returns 0 on success, or -1 on failure.

Notes

This function internally calls getpeername() to obtain the peer’s address.

Prototype

// Not applicable in JS

Prototype

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