Method _Stdio.Fd()->query_address()


Method query_address

string query_address()
string query_address(bool local)

Description

Get address and port of a socket end-point.

Parameter local

If the argument local is not specified, or is 0 (zero), the remote end-point is returned. Otherwise, if local is 1, the local end-point is returned.

Returns

This function returns the address and port of a socket end-point on the form "x.x.x.x port" (IPv4) or "x:x:x:x:x:x:x:x port" (IPv6). IPv6 addresses may use the contracted syntax.

If this file is not a socket, is not connected, or some other error occurs, 0 (zero) is returned and errno() will return the error code.

Throws

An error is thrown if the socket (or file) isn't open.

See also

connect()