You are here: Re: Understanding socket_select routine « PHP Programming Language « IT news, forums, messages
Re: Understanding socket_select routine

Posted by Sjoerd on 12/18/74 11:50

mydejamail@yahoo.co.uk schreef:
> >From examining the code it seems that if socket_select returns a value
> of >= 2 and $sock is find in the $read array will the code flow on to
> the reading portion. What is the significance of having a value of >=2
> in the $ready variable.

$ready contains the number of sockets on which the state has changed.
The code which you posted goes through the loop $ready times, accepting
$sock and putting the result in an empty $client[$i]['sock'].

This is a hard example. It is probably best to try out socket_select
with just one socket. Try what it does and what its return value is.

> $ready = socket_select($read,null,null,null);
> /* if a new connection is being made add it to the client array */
> if (in_array($sock, $read)) {
> for ($i = 0; $i < $max_clients; $i++)
> {
> if ($client[$i]['sock'] == null) {
> $client[$i]['sock'] = socket_accept($sock);
> break;
> }
> elseif ($i == $max_clients - 1)
> print ("too many clients")
> }
> if (--$ready <= 0)
> continue;
> } // end if in_array

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация