Query: socket
OS: osx
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Socket(3pm) Perl Programmers Reference Guide Socket(3pm)NAME"Socket" - networking constants and support functionsSYNOPSIS"Socket" a low-level module used by, among other things, the IO::Socket family of modules. The following examples demonstrate some low- level uses but a practical program would likely use the higher-level API provided by "IO::Socket" or similar instead. use Socket qw(PF_INET SOCK_STREAM pack_sockaddr_in inet_aton); socket(my $socket, PF_INET, SOCK_STREAM, 0) or die "socket: $!"; my $port = getservbyname "echo", "tcp"; connect($socket, pack_sockaddr_in($port, inet_aton("localhost"))) or die "connect: $!"; print $socket "Hello, world! "; print <$socket>; See also the "EXAMPLES" section.DESCRIPTIONThis 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 "