protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Set the protocol to UDP
+ $this->setProtocol('udp');
}
/**
// Set the application instance
$listenerInstance->setNodeInstance($nodeInstance);
- // Set the protocol to UDP
- $listenerInstance->setProtocol('udp');
-
// Return the prepared instance
return $listenerInstance;
}
} // END - if
// Set the option to reuse the port
- $this->debugOutput('LISTENER: Setting re-use address option.');
+ $this->debugOutput('UDP-LISTENER: Setting re-use address option.');
if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) {
// Get socket error code for verification
$socketError = socket_last_error($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());
+ $this->debugOutput('UDP-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
// Now, we want non-blocking mode
- $this->debugOutput('LISTENER: Setting non-blocking mode.');
+ $this->debugOutput('UDP-LISTENER: Setting non-blocking mode.');
if (!socket_set_nonblock($mainSocket)) {
// Get socket error code for verification
$socketError = socket_last_error($socket);
// Remember the socket in our class
$this->registerServerSocketResource($mainSocket);
+ // Initialize the network package handler
+ $handlerInstance = ObjectFactory::createObjectByConfiguredName('udp_raw_data_handler_class');
+
+ // Set it in this class
+ $this->setHandlerInstance($handlerInstance);
+
// Output message
- $this->debugOutput('LISTENER: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+ $this->debugOutput('UDP-LISTENER: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
}
/**
return;
} elseif ($lastError > 0) {
// Other error detected
- $this->debugOutput('LISTENER: Error detected: ' . socket_strerror($lastError));
+ $this->debugOutput('UDP-LISTENER: Error detected: ' . socket_strerror($lastError));
// Skip further processing
return;
} // END - if
// Debug only
- $this->debugOutput('LISTENER: Handling UDP package with size ' . strlen($pkt) . ' from peer ' . $peer . ':' . $port);
+ $this->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($pkt) . ' from peer ' . $peer . ':' . $port);
}
/**