
The @code{Sockets.Naming} package contains types and helper functions
needed to manipulate Internet host names and addresses.

@deftypefn Sockets.Naming.Address type Address is record@*@w{  }H1, H2, H3, H4 : Address_Component;@*end record;
This type represents an IPv4 address with @code{H1} being the first
octet and @code{H4} the last one. For example, 137.194.161.2 is
represented by @code{H1=137, H2=194, H3=161, H4=2}.

@end deftypefn

@deftypefn Sockets.Naming.Address_Array type Address_Array is array (Positive range <>) of Address;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.Address_Component type Address_Component is Natural range 0 .. 255;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.Host_Entry type Host_Entry (N_Aliases, N_Addresses : Natural) is new Ada.Finalization.Controlled with record@*@w{  } Name : String_Access;@*@w{  } Aliases : String_Array (1 .. N_Aliases);@*@w{  } Addresses : Address_Array (1 .. N_Addresses);@* end record;
The @code{Host_Entry} type holds a set of names and IP addresses
associated with a host. Each host can have several IP address
as well as several aliases.

@end deftypefn

@deftypefn Sockets.Naming.String_Access type String_Access is access String;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.String_Array type String_Array is array (Positive range <>) of String_Access;
Helper type

@end deftypefn

@menu
* Address_Of (function)::
                        Get the IP address of a host
* Any_Address (function)::
                        Special address representing any address on the local host
* Get_Peer_Addr (function)::
                        Retrieve IP address of remote host
* Get_Peer_Port (function)::
                        Retrieve IP address of remote host
* Get_Sock_Addr (function)::
                        Retrieve IP address of local host
* Get_Sock_Port (function)::
                        Retrieve IP address of local host
* Host_Name (function)::
                        Get the name of the current host
* Image (function)::    Make a string from an address
* Info_Of_Name_Or_IP (function)::
                        Get addresses and names of a host
* Is_IP_Address (function)::
                        Check if given string is a valid IP address
* Name_Of (function)::  Official name of the host
* Value (function)::    Transform a string into an address
@end menu

@node Address_Of (function)
@unnumberedsubsec Address_Of (function)

@table @sc
@item Purpose
Get the IP address of a host
@item Prototype
@deftypefn Sockets.Naming.Address_Of function Address_Of (@w{@var{Something} : String})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Address_Of

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
IPv4 address


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@item See also
@ref{Name_Of (function)}.

@end table

@node Any_Address (function)
@unnumberedsubsec Any_Address (function)

@table @sc
@item Purpose
Special address representing any address on the local host
@item Prototype
@deftypefn Sockets.Naming.Any_Address function Any_Address
@end deftypefn
@fnindex Sockets.Naming.Any_Address

@item Return value
Equivalent to @code{INADDR_ANY} in the C programming language




@end table

@node Get_Peer_Addr (function)
@unnumberedsubsec Get_Peer_Addr (function)

@table @sc
@item Purpose
Retrieve IP address of remote host
@item Prototype
@deftypefn Sockets.Naming.Get_Peer_Addr function Get_Peer_Addr (@w{@var{Socket} : Socket_FD})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Get_Peer_Addr

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Peer address




@item See also
@ref{Get_Peer_Port (function)},@*@ref{Get_Sock_Addr (function)}.

@end table

@node Get_Peer_Port (function)
@unnumberedsubsec Get_Peer_Port (function)

@table @sc
@item Purpose
Retrieve IP address of remote host
@item Prototype
@deftypefn Sockets.Naming.Get_Peer_Port function Get_Peer_Port (@w{@var{Socket} : Socket_FD})@*@w{return Positive;}
@end deftypefn
@fnindex Sockets.Naming.Get_Peer_Port

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Port used on the remote host




@item See also
@ref{Get_Sock_Port (function)},@*@ref{Get_Peer_Addr (function)}.

@end table

@node Get_Sock_Addr (function)
@unnumberedsubsec Get_Sock_Addr (function)

@table @sc
@item Purpose
Retrieve IP address of local host
@item Prototype
@deftypefn Sockets.Naming.Get_Sock_Addr function Get_Sock_Addr (@w{@var{Socket} : Socket_FD})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Get_Sock_Addr

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Address of local interface used




@item See also
@ref{Get_Sock_Port (function)},@*@ref{Get_Peer_Addr (function)}.

@end table

@node Get_Sock_Port (function)
@unnumberedsubsec Get_Sock_Port (function)

@table @sc
@item Purpose
Retrieve IP address of local host
@item Prototype
@deftypefn Sockets.Naming.Get_Sock_Port function Get_Sock_Port (@w{@var{Socket} : Socket_FD})@*@w{return Positive;}
@end deftypefn
@fnindex Sockets.Naming.Get_Sock_Port

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Port used on the local host




@item See also
@ref{Get_Peer_Port (function)},@*@ref{Get_Sock_Addr (function)}.

@end table

@node Host_Name (function)
@unnumberedsubsec Host_Name (function)

@table @sc
@item Purpose
Get the name of the current host
@item Prototype
@deftypefn Sockets.Naming.Host_Name function Host_Name
@end deftypefn
@fnindex Sockets.Naming.Host_Name

@item Return value
Name of the current host

@item Description
This function returns the name of the current host. Depending on
the local configuration, it may or may not be a fully qualified
domain name (FQDN).




@end table

@node Image (function)
@unnumberedsubsec Image (function)
@cindex Representing IP addresses

@table @sc
@item Purpose
Make a string from an address
@item Prototype
@deftypefn Sockets.Naming.Image function Image (@w{@var{Add} : Address})@*@w{return String;}
@end deftypefn
@fnindex Sockets.Naming.Image

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Add} @tab in @tab IP address
@end multitable

@item Return value
String representation of the IP address




@item See also
@ref{Value (function)}.

@end table

@node Info_Of_Name_Or_IP (function)
@unnumberedsubsec Info_Of_Name_Or_IP (function)

@table @sc
@item Purpose
Get addresses and names of a host
@item Prototype
@deftypefn Sockets.Naming.Info_Of_Name_Or_IP function Info_Of_Name_Or_IP (@w{@var{Something} : String})@*@w{return Host_Entry;}
@end deftypefn
@fnindex Sockets.Naming.Info_Of_Name_Or_IP

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
Corresponding host entry

@item Description
This function extracts all the names and addresses from the
naming service.


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@end table

@node Is_IP_Address (function)
@unnumberedsubsec Is_IP_Address (function)

@table @sc
@item Purpose
Check if given string is a valid IP address
@item Prototype
@deftypefn Sockets.Naming.Is_IP_Address function Is_IP_Address (@w{@var{Something} : String})@*@w{return Boolean;}
@end deftypefn
@fnindex Sockets.Naming.Is_IP_Address

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab String to check
@end multitable

@item Return value
@samp{True} if @var{Something} is an IP address




@end table

@node Name_Of (function)
@unnumberedsubsec Name_Of (function)

@table @sc
@item Purpose
Official name of the host
@item Prototype
@deftypefn Sockets.Naming.Name_Of function Name_Of (@w{@var{Something} : String})@*@w{return String;}
@end deftypefn
@fnindex Sockets.Naming.Name_Of

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
Name of the host


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@item See also
@ref{Address_Of (function)}.

@end table

@node Value (function)
@unnumberedsubsec Value (function)
@cindex Representing IP addresses

@table @sc
@item Purpose
Transform a string into an address
@item Prototype
@deftypefn Sockets.Naming.Value function Value (@w{@var{Add} : String})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Value

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Add} @tab in @tab Textual representation of an IP address
@end multitable

@item Return value
Corresponding Address




@item See also
@ref{Image (function)}.

@end table


