start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: 3.2.3 abs Chapter 3
Functions
Next: 3.2.5 alarm
 

3.2.4 accept

accept 

NEWSOCKET

, 

GENERICSOCKET

This function does the same thing as the accept system call - see accept (2). It is used by server processes that wish to accept socket connections from clients. Execution is suspended until a connection is made, at which time the NEWSOCKET filehandle is opened and attached to the newly made connection. The function returns the connected address if the call succeeded, false otherwise (and puts the error code into $! ). GENERICSOCKET must be a filehandle already opened via the socket operator and bound to one of the server's network addresses. For example:

unless ($peer = accept NS, S) {     die "Can't accept a connection: $!\n"; }

See also the example in the section "Sockets" in Chapter 6, Social Engineering .


Previous: 3.2.3 abs Programming Perl Next: 3.2.5 alarm
3.2.3 abs Book Index 3.2.5 alarm