namespace Network

A set of functions useful for network operations

namespace attributes [NB. highlighted items are covered in other pages - namespaces or classes]
variable ANY4 - This is used as the mask on which to bind to any IPV4 network address
variable ANY6 - This is used as the mask on which to bind to any IPV6 network address
variable AF_IPV4 - This is used to indicate that an IP address is a version 4 one.
variable AF_IPV6 - This is used to indicate that an IP address is a version 6 one.
variable AF_AUTO - This tells a function to use IPV6 if possible or fall back on IPV4
function tcp_connect() - Connect to a host on a specified host and port
function tcp_bind() - Create a socket bound to a TCP port
function unix_connect() - Connect to a Unix domain socket at the specified location
function unix_bind() - Bind to a Unix domain socket
function inet_aton() - Converts an IPV4 numbers-and-dots notation address to a number
function inet_ntoa() - Converts an IPV4 address number to text form
function getHostname() - Returns the system hostname as a string
class Service - Stores information about a network service
function getServiceByPort() - Returns a Service object corresponding to the specified service
function getServiceByName() - Returns a Service object corresponding to the specified service
class Host - Finds information about a network host
class UDPSocket - Used for sending and receiving UDP datagrams

Functions

function tcp_connect Click to go up to the list
Connect to a host on a specified host and port
Declaration:
    native function tcp_connect(string host, number port, number af)
Description:
This function attempts to create a TCP socket connected to the specified remote address and port, and if it succeeds, returns a Sys.TcpStream object. If the address family is Network.AF_IPV4, connect will look for an IPV4 address with that name and fail if it doesn't find one. If it is Network.AF_IPV6, it will look for an IPV6 address and fail if it doesn't find one. If it is Network.AF_AUTO, it will try to find an IPV6 address, then try to find an IPV4 address, and only fail if it doesn't find either. Note: you can leave off the af parameter if you wish, and it will default to Network.AF_AUTO.
Parameters:
    Parameter #1: string host - The host to connect to
    Parameter #2: number port - The port to connect to
    Parameter #3: number af - The address family to use
Returns:
    An object connected to the host, or null on failure

function tcp_bind Click to go up to the list
Create a socket bound to a TCP port
Declaration:
    native function tcp_bind(string host, number port, number af)
Description:
This function attempts to create a TCP socket bound to the specified address and port, and if it succeeds, returns a Sys.TcpStream object. The address to bind to can be Network.ANY4 to bind to every IPV4 address or Network.ANY6 to bind to every IPV6 address. If the address family is Network.AF_IPV4, bind will look for an IPV4 address with that name and fail if it doesn't find one. If it is Network.AF_IPV6, it will look for an IPV6 address and fail if it doesn't find one. If it is Network.AF_AUTO, it will try to find an IPV6 address, then try to find an IPV4 address, and only fail if it doesn't find either. Note: you can leave off the af parameter if you wish, and it will default to Network.AF_AUTO.
Parameters:
    Parameter #1: string host - The address to bind to
    Parameter #2: number port - The port to listen on, use 0 for any port
    Parameter #3: number af - The address family to use
Returns:
    An object that can accept connections, or null on error.

function unix_connect Click to go up to the list
Connect to a Unix domain socket at the specified location
Declaration:
    native function unix_connect(string path)
Parameters:
    Parameter #1: string path - The full path to the named socket
Returns:
    An object connected to the named socket, or null if the connection could not be established

function unix_bind Click to go up to the list
Bind to a Unix domain socket
Declaration:
    native function unix_bind(string path)
Description:
Creates a UnixStream object bound to the specified Unix domain socket. Note that the bind will fail if the file already exists, and Unix domain sockets are not automatically deleted when the server closes them, so you may need to delete a stale socket file before you can bind to it.
Parameters:
    Parameter #1: string path - The full path to the file to use as the named socket
Returns:
    An object that can accept connections, or null on error

function inet_aton Click to go up to the list
Converts an IPV4 numbers-and-dots notation address to a number
Declaration:
    native function inet_aton( string host )
Description:
Converts an IPV4 text format address (eg. "127.0.0.1") into a number. Note that this function is officially deprecated (in favour of inet_pton() which Ferite does not have a binding to yet) and you should not rely on it if you want your application to be portable to IPV6 in the future.
Parameters:
    Parameter #1: string host - The hostaddress in numbers-and-dots notation
Returns:
    A number containing the IPV4 adress, 0 if the string was invalid

function inet_ntoa Click to go up to the list
Converts an IPV4 address number to text form
Declaration:
    native function inet_ntoa( number ip )
Description:
Converts an IPV4 numeric address into a dots-and-numbers notation string (eg. "127.0.0.1"). Note that this function is officially deprecated (in favour of inet_ntop() which Ferite does not have a binding to yet) and you should not rely on it if you want your application to be portable to IPV6 in the future.
Parameters:
    Parameter #1: number ip - The IPV4 adress in number form
Returns:
    The string containing the IPV4 address in text form

function getHostname Click to go up to the list
Returns the system hostname as a string
Declaration:
    native function getHostname()
Returns:
    The system hostname

function getServiceByPort Click to go up to the list
Returns a Service object corresponding to the specified service
Declaration:
    native function getServiceByPort(number port, number proto)
Description:
This function searches the system service database (typically stored in /etc/services) for a service with the specified port number (in host byte order) and protocol, and if it finds one, it returns the record as an instance of the class Network.Service. If it doesn't find a matching service, it returns NULL. The protocol should be a string, usually either "tcp" or "udp". Alternatively an empty string ("") means "any protocol".
Parameters:
    Parameter #1: number port - The port number of the service to look for
    Parameter #2: string proto - The protocol of the service to look for
Returns:
    A Service object, or null on failure

function getServiceByName Click to go up to the list
Returns a Service object corresponding to the specified service
Declaration:
    native function getServiceByName(string name, number proto)
Description:
This function searches the system service database (typically stored in /etc/services) for a service with the specified name and protocol, and if it finds one, it returns the record as an instance of the class Network.Service. If it doesn't find a matching service, it returns NULL. The protocol should be a string, usually either "tcp" or "udp". Alternatively an empty string ("") means "any protocol". Note that if the name you search for is an alias, the name variable of the Service object which is returned will contain the primary name for the service instead of the name you searched for.
Parameters:
    Parameter #1: string name - The name of the service to look for
    Parameter #2: string proto - The protocol of the service to look for
Returns:
    A Service object, or null on failure

Variables

string ANY4 Click to go up to the list
This is used as the mask on which to bind to any IPV4 network address

string ANY6 Click to go up to the list
This is used as the mask on which to bind to any IPV6 network address

number AF_IPV4 Click to go up to the list
This is used to indicate that an IP address is a version 4 one.

number AF_IPV6 Click to go up to the list
This is used to indicate that an IP address is a version 6 one.

number AF_AUTO Click to go up to the list
This tells a function to use IPV6 if possible or fall back on IPV4

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.