protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Set the protocol to TCP
+ $this->setProtocol('tcp');
}
/**
// Set the application instance
$listenerInstance->setNodeInstance($nodeInstance);
- // Set the protocol to TCP
- $listenerInstance->setProtocol('tcp');
-
// Return the prepared instance
return $listenerInstance;
}
// "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());
+ $this->debugOutput('TCP-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);
} // END - if
// Start listen for connections
- $this->debugOutput('LISTENER: Listening for connections.');
+ $this->debugOutput('TCP-LISTENER: Listening for connections.');
if (!socket_listen($mainSocket)) {
// Get socket error code for verification
$socketError = socket_last_error($mainSocket);
} // END - if
// Now, we want non-blocking mode
- $this->debugOutput('LISTENER: Setting non-blocking mode.');
+ $this->debugOutput('TCP-LISTENER: Setting non-blocking mode.');
if (!socket_set_nonblock($mainSocket)) {
// Get socket error code for verification
$socketError = socket_last_error($mainSocket);
$this->setIteratorInstance($iteratorInstance);
// Initialize the network package handler
- $handlerInstance = ObjectFactory::createObjectByConfiguredName('tcp_network_package_handler_class');
+ $handlerInstance = ObjectFactory::createObjectByConfiguredName('tcp_raw_data_handler_class');
// Set it in this class
$this->setHandlerInstance($handlerInstance);
// Output message
- $this->debugOutput('LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+ $this->debugOutput('TCP-LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
}
/**
if (in_array($this->getSocketResource(), $readers)) {
// Then accept it
$newSocket = socket_accept($this->getSocketResource());
- //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: newSocket=' . $newSocket);
+ //* NOISY-DEBUG: */ $this->debugOutput('TCP-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'
- //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: currentSocket=' . $currentSocket);
+ //* NOISY-DEBUG: */ $this->debugOutput('TCP-LISTENER: currentSocket=' . $currentSocket);
$this->getHandlerInstance()->processRawDataFromResource($currentSocket);
} // END - if