PackageDescription | This module provides a variety of constants, structure manipulators and
other functions related to socket-based networking. The values and
functions provided are useful when used in conjunction with Perl core
functions such as socket(), setsockopt() and bind(). It also provides
several other support functions, mostly for dealing with conversions of
network addresses between human-readable and native binary forms, and for
hostname resolver operations.
Some constants and functions are exported by default by this module; but
for backward-compatibility any recently-added symbols are not exported by
default and must be requested explicitly. When an import list is provided
to the 'use Socket' line, the default exports are not automatically
imported. It is therefore best practice to always to explicitly list all
the symbols required.
Also, some common socket "newline" constants are provided: the constants
'CR', 'LF', and 'CRLF', as well as '$CR', '$LF', and '$CRLF', which map to
'\015', '\012', and '\015\012'. If you do not want to use the literal
characters in your programs, then use the constants provided here. They are
not exported by default, but can be imported individually, and with the
':crlf' export tag:
use Socket qw(:DEFAULT :crlf);
$sock->print("GET / HTTP/1.0$CRLF");
The entire getaddrinfo() subsystem can be exported using the tag
':addrinfo'; this exports the getaddrinfo() and getnameinfo() functions,
and all the 'AI_*', 'NI_*', 'NIx_*' and 'EAI_*' constants. |