Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using IO::Select in multi-client environment

Status
Not open for further replies.

dbar1

Programmer
Joined
Feb 14, 2007
Messages
1
Location
US
Hi,
I am trying to use select call in multi-client model.
Here's what my code does.
# Create a socket
$sockSel = new IO::Select( $servSock );

while ( @ready = $sockSel->can_read )
{
foreach $fh ( @ready )
if ( $fh == $servSock )
{
$newConn = $servSock->accept();
$sockSel->add($newConn);
}
else
{
$fh->recv($sockBuff,$maxLenMsg);
if($sockBuff)
{ # Process sockBuff
}
}
}

Now, when one client connects, my code blocks till the sockBuff from that client is processed. In the meantime, it cannot serve any other clients.
Is there a way around this? I want to serve the next client when the 1st client is getting processed. Can I avoid threads and still achieve this with select? Thanks
 
I wouldn't think so on the same port, but you can assign a number of ports to deal with clients, and allocate them round robin

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top