accept

acceptSOCKET,PROTOSOCKET
This function is used by server processes that wish to listen
for socket connections from clients.
PROTOSOCKET must be a filehandle already
opened via the socket operator and
bound to one of the server’s network addresses or to INADDR_ANY. Execution is suspended until a
connection is made, at which point the SOCKET
filehandle is opened and attached to the newly made connection. The
original PROTOSOCKET remains unchanged; its
sole purpose is to be cloned into a real socket. The function returns
the connected address if the call succeeds, false otherwise. For
example:
unless ($peer = accept(SOCKET,PROTOSOCK)) { die "Can't accept a connection: $!"; }
On systems that support it, the close-on-exec flag will be set for
the newly opened file descriptor, as determined by the value of $^F ($SYSTEM_FD_MAX).
See accept(2). See also the example in the section Sockets in Chapter 15.
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