February 2012
Intermediate to advanced
1184 pages
37h 17m
English
connectSOCKET,NAME
This function initiates a connection with another process that
is waiting at an accept. The function
returns true if it succeeded, false otherwise.
NAME should be a packed network address of
the proper type for the socket. For example, assuming SOCK is a previously created socket:
use Socket;
my ($remote, $port) = ("www.perl.com", 80);
my $destaddr = sockaddr_in($port, inet_aton($remote));
connect(SOCK, $destaddr)
|| die "Can't connect to $remote at port $port: $!";To disconnect a socket, use either close or shutdown. See also the examples in the section
Sockets in Chapter 15. See
connect(2). For most socket operations, the
higher-level interface provided by the standard IO::Socket module is preferred.
Read now
Unlock full access