+ $this->debugOutput('LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+ }
+
+ /**
+ * "Listens" for incoming network packages
+ *
+ * @return void
+ * @throws InvalidSocketException If an invalid socket resource has been found
+ */
+ public function doListen () {
+ // Get all readers
+ $readers = $this->getPoolInstance()->getAllSockets();
+ $writers = array();
+ $excepts = array();
+
+ // Check if we have some peers left
+ $left = socket_select(
+ $readers,
+ $writers,
+ $excepts,
+ 0,
+ 150
+ );
+
+ // Some new peers found?
+ if ($left < 1) {
+ // Nothing new found
+ return;
+ } // END - if
+
+ // Do we have changed peers?
+ if (in_array($this->getSocketResource(), $readers)) {
+ // Then accept it
+ $newSocket = socket_accept($this->getSocketResource());
+ //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: newSocket=' . $newSocket);
+
+ // We want non-blocking here, too
+ if (!socket_set_nonblock($newSocket)) {
+ // Get socket error code for verification
+ $socketError = socket_last_error($newSocket);
+
+ // Get error message
+ $errorMessage = socket_strerror($socketError);
+
+ // Shutdown this socket
+ $this->shutdownSocket($newSocket);
+
+ // And throw the exception
+ throw new InvalidSocketException(array($this, gettype($newSocket), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
+ // Add it to the peers
+ $this->getPoolInstance()->addPeer($newSocket);
+ } // END - if
+
+ // Do we have to rewind?
+ if (!$this->getIteratorInstance()->valid()) {
+ // Rewind the list
+ $this->getIteratorInstance()->rewind();
+ } // END - if
+
+ // Get the current value
+ $currentSocket = $this->getIteratorInstance()->current();
+
+ // Handle it here, if not main socket
+ if ($currentSocket != $this->getSocketResource()) {
+ // ... or else it will raise warnings like 'Transport endpoint is not connected'
+ //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: currentSocket=' . $currentSocket);
+ $this->getPackageInstance()->processResourcePackage($currentSocket);
+ } // END - if
+
+ // Advance to next entry. This should be the last line
+ $this->getIteratorInstance()->next();
+ }
+
+ /**
+ * Checks wether the listener would accept the given package data array
+ *
+ * @param $packageData Raw package data
+ * @return $accepts Wether this listener does accept
+ */
+ function ifListenerAcceptsPackageData (array $packageData) {
+ $this->partialStub('This call should not happen. Please report.');