Socket Functions Related to Outgoing Connections
We'll now look at the functions related to creating sockets and establishing outgoing TCP connections in more detail.
|
$boolean = socket (SOCKET,$domain,$type,$protocol) Given a filehandle name, a domain, a type, and a protocol, socket() creates a new socket and associates it with the named filehandle. On success, the function returns a true value. On error, socket() returns undef and leaves the error message in $!. The domain, type, and protocol are all small integers. Appropriate values for the first two are constants defined in the Socket module, but the protocol value must be determined at run time by calling getprotobyname(). For creating TCP sockets, the idiom is typically socket(SOCK,AF_INET,SOCK_STREAM, ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access