note 106102 added to function.stream-socket-accept
| From: | Andy at txtNation dot com | Date: | Mon, 10 Oct 2011 16:13:37 +0000 |
| Subject: | note 106102 added to function.stream-socket-accept | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183773@lists.php.net to get a copy of this message | ||
To check if there's a new connection waiting, without blocking, or (when using non-blocking
mode) without notices), you can use stream_accept (as opposed to socket_select).
<?php
class GenericClass {
protected $resSocket=null;
function acceptConnections() {
# check that we still have a resource
if(is_resource($this->resSocket)) {
$arrRead=array($this->resSocket);
$arrWrite=array();
/** @warning Passing $arrRead,$arrWrite by reference */
if(stream_select($arrRead,$arrWrite,$arrWrite,0)) {
$resConnection=stream_socket_accept($this->resSocket,0);
# ... other stuff here
}
}
}
}
?>
----
Server IP: 87.124.126.117
Probable Submitter: 82.32.254.149 (proxied: 82.32.254.149)
----
Manual Page -- http://www.php.net/manual/en/function.stream-socket-accept.php
Edit -- https://master.php.net/note/edit/106102
Del: integrated -- https://master.php.net/note/delete/106102/integrated
Del: useless -- https://master.php.net/note/delete/106102/useless
Del: bad code -- https://master.php.net/note/delete/106102/bad+code
Del: spam -- https://master.php.net/note/delete/106102/spam
Del: non-english -- https://master.php.net/note/delete/106102/non-english
Del: in docs -- https://master.php.net/note/delete/106102/in+docs
Del: other reasons-- https://master.php.net/note/delete/106102
Reject -- https://master.php.net/note/reject/106102
Search -- https://master.php.net/manage/user-notes.php