Perl Programming/Keywords/socket

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: sleep Keywords Next: socketpair

The socket keyword

[edit | edit source]

The socket function opens a socket of the specified kind and attaches it to filehandle SOCKET. The DOMAIN, TYPE, and PROTOCOL are specified in the same way as for syscall.

Syntax

[edit | edit source]
  socket SOCKET, DOMAIN, TYPE, PROTOCOL

Examples

[edit | edit source]
use Socket;

$proto = getprotobyname("tcp");

socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";

Examples

[edit | edit source]
Previous: sleep Keywords Next: socketpair