IO::Socket::INET Reference

An Internet-domain socket is created with the new method from the IO::Socket::INET subclass. The constructor can take the following options:

PeerAddr => hostname [:port ]

Specifies the remote host and optional port number for a client connection. hostname can be either a name, such as www.oreilly.com, or an IP number of the form 207.44.21.2.

PeerPort => port

Specifies the port number on the remote host for a client connection. The name of the service (such as http or nntp) may be used for the argument if the port number is not known.

LocalAddr => hostname[:port]

Specifies the local address (and optional port number) to bind to a server-side socket.

LocalPort => port

Specifies the local port number (or service name) to bind to a server-side socket.

Proto => name

Specifies the protocol to be run on the socket, i.e., tcp or udp.

Type => SOCK_STREAM | SOCK_DGRAM

Specifies the type of socket. SOCK_STREAM indicates a stream-based socket connection, and SOCK_DGRAM indicates a message-based (datagram) connection.

Listen => n

Sets the listen-queue size to n number of client requests.

Reuse => 1

Given a nonzero number, this option allows the local bind address to be reused should the socket need to be reopened after an error.

Timeout => n

Sets the timeout.

Whether a server (receiving) or client (requesting) socket is created depends on the parameters provided to the constructor. If Listen is defined, a server socket is automatically created. If no protocol is specified, it is derived ...

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.