[ale] RE: listen()

Joe Steele joe at madewell.com
Thu Feb 20 10:09:42 EST 2003


As I recall, you wanted to process only one 
connection at a time, rejecting additional connection 
requests until the current connection was closed.

You probably need to do something like this:

do
{
	sock1 = socket (...);
	bind (sock1,...);
	listen (sock1, 1);
	sock2 = accept (sock1,...);

	/* stop listening for other connection attempts */
	close (sock1); 
	
	/* Service the connection on sock2 */
	.
	.
	.
	/* terminate the connection */
	close (sock2);

	/* loop back and listen for another connection */
} while (continue_listening); 


--Joe


-----Original Message-----
From:	cfowler [SMTP:cfowler at outpostsentinel.com]
Sent:	Wednesday, February 19, 2003 1:27 PM
To:	ale at ale.org
Subject:	[ale] RE: listen()

I have deleted my emails but a few weeks ago someone mentioned that I
should do an accept() instead of listen() -> accept() to get only one
connection. I tried that.

>>From accept(2);

The argument s is a socket that has been created with socket(2), bound
to a local address  with  bind(2), and is listening for connections
after a listen(2).

Maybe this trick works in BSD but not in Linux.  accept() gave me an
immediate error.

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list