Beispiel #1
0
 /**
  * Creates a new socket from an incomming connection to a server
  * socket
  *
  * @param Net_Notifier_Socket_Server $serverSocket the server socket
  *                                                 receiving the incomming
  *                                                 connection.
  * @param integer                    $timeout      the connection timeout
  *                                                 in seconds.
  *
  * @throws Net_Notifier_Socket_ConnectionException
  */
 public function __construct(Net_Notifier_Socket_Server $serverSocket, $timeout)
 {
     set_error_handler(array($this, 'connectionWarningsHandler'));
     $this->socket = stream_socket_accept($serverSocket->getRawSocket(), $timeout);
     restore_error_handler();
     if (!$this->socket) {
         $error = implode("\n", $this->connectionWarnings);
         throw new Net_Notifier_Socket_ConnectionException("Unable to accept client connection. Error: {$error}");
     }
 }
Beispiel #2
0
 /**
  * Gets an array of sockets to check for reading
  *
  * @return array an aray of sockets to check for reading.
  */
 protected function &getReadArray()
 {
     $readArray = array();
     $readArray[] = $this->socket->getRawSocket();
     foreach ($this->clients as $client) {
         if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) {
             $readArray[] = $client->getSocket()->getRawSocket();
         }
     }
     return $readArray;
 }