Pike v8.1 release 6

Method NetUtils.ip_of()


Method ip_of

string ip_of(RemoteAddressObject|string|int(0..0) inc, bool|void local_address, string|void def)

Description

If the argument is an object with a query_address method, return the IP# part of the string returned by calling that function with local_address as the argument.

This means that for Stdio.File objects the remote address is returned by default, but if local_address is true the local address is returned.

If the argument is a string instead, the part of the string before the first space is returned.

If the argument is 0 the default def value is returned, UNDEFINED unless specified.

If def is supplied, it is used both when query_address() fails or something that is not a file descriptor object or a string is passed as the argument to this function.