*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
throw new InvalidSocketException(array($this, gettype($mainSocket), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
- // Now, we want non-blocking mode
- $this->debugOutput('LISTENER: Setting non-blocking mode.');
- if (!socket_set_nonblock($mainSocket)) {
+ // "Bind" the socket to the given address, on given port so this means
+ // that all connections on this port are now our resposibility to
+ // send/recv data, disconnect, etc..
+ $this->debugOutput('LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+ if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
// Get socket error code for verification
$socketError = socket_last_error($mainSocket);
throw new InvalidSocketException(array($this, gettype($mainSocket), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
- // "Bind" the socket to the given address, on given port so this means
- // that all connections on this port are now our resposibility to
- // send/recv data, disconnect, etc..
- $this->debugOutput('LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
- if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
+ // Start listen for connections
+ $this->debugOutput('LISTENER: Listening for connections.');
+ if (!socket_listen($mainSocket)) {
// Get socket error code for verification
$socketError = socket_last_error($mainSocket);
throw new InvalidSocketException(array($this, gettype($mainSocket), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
- // Start listen for connections
- $this->debugOutput('LISTENER: Listening for connections.');
- if (!socket_listen($mainSocket)) {
+ // Now, we want non-blocking mode
+ $this->debugOutput('LISTENER: Setting non-blocking mode.');
+ if (!socket_set_nonblock($mainSocket)) {
// Get socket error code for verification
$socketError = socket_last_error($mainSocket);
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)) {
// Handle it here, if not main socket
if ($currentSocket != $this->getSocketResource()) {
// ... or else it will raise warnings like 'Transport endpoint is not connected'
- $this->getPackageInstance()->processResourcePackage($currentSocket);
+ //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: currentSocket=' . $currentSocket);
+ $this->getPackageInstance()->processResourceRawData($currentSocket);
} // END - if
// Advance to next entry. This should be the last line
* @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.');
+ public function ifListenerAcceptsPackageData (array $packageData) {
+ $this->partialStub('This call should not happen. Please report it.');
}
}