PERL accept Function

Syntax

accept NEWSOCKET,GENERICSOCKET

Definition and Usage

Accepts an incoming connection on the existing GENERICSOCKET, which should have been created with socket and bound to a local address using bind. The new socket, which will be used for communication with the client will be NEWSOCKET. GENERICSOCKET will remain unchanged.

Returned Value

  • 0 on failure
  • Packed address of remote host on success

Example

Have a look at socket example in Perl Socket Session.
You will often see accept() used inside a while loop as follows
  while(1) {
accept( NEW_SOCKET, SOCKT );
.......
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s