2.12.6Functions

getHostName

Retreives the host name of the local machine.

getHostName()
ReturnA string containing the local machine name.
Raise
NetError if the host name can't be determined.

Returns the network name under which the machine is known to itself. By calling resolveAddress on this host name, it is possible to determine all the addressess of the interfaces that are available for networking.

If the system cannot provide an host name for the local machine, a NetError is raised.

Note: If the function fails, it is possible to retreive local addresses using through resolveAddress using the the name "localhost".

resolveAddress

Resolve a network address in a list of numeric IP fields.

resolveAddress( address )
address An host name, quad dot IP address or IPV6 address.
ReturnAn array of IPv4 or IPv6 addresses.
Raise
NetError if the name resolution service is not available.

This function tries to resolve an address or an host name into a list of addresses that can be used to connect directly via the protocols that are available on the machine. The way in which the function can resolve the addresses depends on the string that has been given, on the underlying system and on the name resolution services that the system can access. Also, the time by which a positive or negative result can be returned varies greatly between different systems. The caller must consider this function as potentially blocking the VM for a long time.

The other members of the Socket module do not need to be provided with already resolved addresses. In example, the connect method of the TCPSocket class can be provided with a host name or with an IP address; in the first case, the connect method will resolve the target address on its own.

This function can be used on the value returned by getHostName, or using "localhost" as the address parameter, to receive a list of the interfaces that are available under the network name of the host the VM is running on. This is useful to i.e. bind some services only to one of the available interfaces.

The values in the returned array are the ones provided by the underlying name resolution system. They are not necessarily unique, and their order may change across different calls.

If the function cannot find any host with the given name, an empty array is returned; if the name resolution service is not accessible, or if accessing it causes a system error, the function will raise a NetError.

socketErrorDesc

Describe the meaning of a networking related system error code.

socketErrorDesc( code )
code The error code to be described.
ReturnA string with a textual description of the error.

This function invokes the system code-to-meaning translation for networking errors. The language in which the error code is described depends on the underlying system,

The function can be applied to the fsError field of the NetError class to get a descriptive reason of why some operation failed, or on Socket.lastError.

Made with http://www.falconpl.org