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

Posted by Chung Leong on 06/06/06 16:12

mydejamail@yahoo.co.uk wrote:
> I have begun dabbling in php socket programming, and I have been trying
> to get the hang of the socket_select command based on the example here
> - http://www.zend.com/pecl/tutorials/sockets.php.
>
> >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.

In the example, socket_select() is used to watch for two types of
events: new connections and availability of data. $sock is different
from the other sockets in the array in that it's not really connected
to anything. It's sort of a placeholder for a new socket. When it
becomes readable, it means there's a new incoming connection, and you
call socket_accept() to get the actual socket for that new connection.

So $ready is the number of new connections (1 or 0) plus the number of
sockets with readable data. If it's 1 and the socket is $sock, then
there are no sockets with readable data.

 

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

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