+ $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry));
+ }
+
+ /**
+ * Setter for protocol
+ *
+ * @param $protocol Used protocol
+ * @return void
+ */
+ protected final function setProtocol ($protocol) {
+ $this->protocol = (string) $protocol;
+ }
+
+ /**
+ * Getter for protocol
+ *
+ * @return $protocol Used protocol
+ */
+ public final function getProtocol () {
+ return $this->protocol;
+ }
+
+ /**
+ * Setter for blocking-mode
+ *
+ * @param $blockingMode Wether blocking-mode is disabled (default) or enabled
+ * @return void
+ */
+ protected final function setBlockingMode ($blockingMode) {
+ $this->blockingMode = (boolean) $blockingMode;
+ }
+
+ /**
+ * Checks wether blocking-mode is enabled or disabled
+ *
+ * @return $blockingMode Wether blocking mode is disabled or enabled
+ */
+ public final function isBlockingModeEnabled () {
+ return $this->blockingMode;
+ }
+
+ /**
+ * Setter for peer pool instance
+ *
+ * @param $poolInstance The peer pool instance we shall set
+ * @return void
+ */
+ protected final function setPoolInstance (PoolablePeer $poolInstance) {
+ $this->poolInstance = $poolInstance;
+ }
+
+ /**
+ * Getter for peer pool instance
+ *
+ * @return $poolInstance The peer pool instance we shall set
+ */
+ public final function getPoolInstance () {
+ return $this->poolInstance;
+ }
+
+ /**
+ * Registeres the given socket resource for "this" listener instance. This
+ * will be done in a seperate class to allow package writers to use it
+ * again.
+ *
+ * @param $socketResource A valid server socket resource
+ * @return void
+ * @throws InvalidServerSocketException If the given resource is no server socket
+ * @throws SocketAlreadyRegisteredException If the given resource is already registered
+ */
+ protected function registerServerSocketResource ($socketResource) {
+ // First check if it is valid
+ if (!$this->isServerSocketResource($socketResource)) {
+ // No server socket
+ throw new InvalidServerSocketException(array($this, $socketResource), self::EXCEPTION_INVALID_SOCKET);
+ } elseif ($this->isServerSocketRegistered($socketResource)) {
+ // Already registered
+ throw new SocketAlreadyRegisteredException($this, self::EXCEPTION_SOCKET_ALREADY_REGISTERED);
+ }
+
+ // Get a socket registry instance (singleton)
+ $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
+
+ // Register the socket
+ $registryInstance->registerSocket($this, $socketResource);
+ }
+
+ /**
+ * Checks wether given socket resource is registered in socket registry
+ *
+ * @param $socketResource A valid server socket resource
+ * @return $isRegistered Wether given server socket is registered
+ */
+ protected function isServerSocketRegistered ($socketResource) {
+ // Get a socket registry instance (singleton)
+ $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
+
+ // Check it
+ $isRegistered = $registryInstance->isSocketRegistered($this, $socketResource);
+
+ // Return result
+ return $isRegistered;
+ }
+
+ /**
+ * Getter for "this" socket resource
+ *
+ * @return $socketResource A valid socket resource
+ */
+ public final function getSocketResource () {
+ // Get a socket registry instance (singleton)
+ $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
+
+ // Get the socket resource
+ $socketResource = $registryInstance->getRegisteredSocketResource($this);
+
+ // Return it
+ return $socketResource;
+ }
+
+ /**
+ * Accepts the visitor to process the visit "request"
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Debug message
+ //* DEBUG: */ $this->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
+
+ // Visit this listener
+ $visitorInstance->visitListener($this);
+
+ // Visit the pool if set
+ if ($this->getPoolInstance() instanceof Poolable) {
+ $this->getPoolInstance()->accept($visitorInstance);
+ } // END - if
+
+ // Debug message
+ //* DEBUG: */ $this->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
+ }
+
+ /**
+ * Monitors incoming raw data from the handler and transfers it to the
+ * given receiver instance. This method should not be called, please call
+ * the decorator's version instead to seperator node/client traffic.
+ *
+ * @param $receiverInstance An instance of a Receivable class
+ * @return void
+ * @throws UnsupportedOperatorException If this method is called by a mistake
+ */
+ public function monitorIncomingRawData (Receivable $receiverInstance) {
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $receiverInstance), self::EXCEPTION_UNSPPORTED_OPERATION);