* @return $result Result from listening on socket
* @throws InvalidSocketException If stored socket is invalid
*/
- public function listenOnSocket () {
+ public function listenToSocket () {
// Should be valid socket
if (!$this->isValidSocket()) {
// Throw exception
return $result;
}
+ /**
+ * Tries to enable option "reuse address"
+ *
+ * @return void
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ public function enableSocketReuseAddress () {
+ // Should be valid socket
+ if (!$this->isValidSocket()) {
+ // Throw exception
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
+ // Tries to set option
+ $result = socket_set_option($this->getSocketResource(), SOL_SOCKET, SO_REUSEADDR, 1);
+
+ // Return result
+ return $result;
+ }
+
/**
* Do the shutdown sequence for this connection helper
*
// Start listen for connections
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.');
- if (!$socketInstance->listenOnSocket()) {
+ if (!$socketInstance->listenToSocket()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData));
} // END - if
} // END - if
// Set the option to reuse the port
- // @TODO: , SOL_SOCKET, SO_REUSEADDR, 1
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
if (!$socketInstance->enableSocketReuseAddress()) {
// Handle this socket error with a faked recipientData array
*/
const CONNECTION_TYPE_SERVER = 'server';
- /**
- * Name of used protocol for this connection
- */
- private $connectionType = 'invalid';
-
/**
* (IP) Adress used
*/
return $class;
}
- /**
- * Getter for connection type
- *
- * @return $connectionType Name of used protocol in this connection
- */
- public final function getConnectionType () {
- return $this->connectionType;
- }
-
- /**
- * Setter for connection type
- *
- * @param $connectionType Name of used protocol in this connection
- * @return void
- */
- protected final function setConnectionType ($connectionType) {
- $this->connectionType = $connectionType;
- }
-
/**
* Getter for IP address
*
// And return it
return $iteratorInstance;
}
-}
-// [EOF]
-?>
+}
<?php
+// Own namespace
+namespace Hub\Iterator\Ping;
+
+// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
+
+// Import SPL stuff
+use \Iterator;
+
/**
* A HubPing iterator
*
namespace Hub\Iterator\Network\Listener;
// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
use CoreFramework\Lists\Listable;
+// Import SPL stuff
+use \Iterator;
+
/**
* A NetworkListen iterator
*
<?php
+// Own namespace
+namespace Hub\Iterator\Handler\;
+
+// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
+
+// Import SPL stuff
+use \Iterator;
+
/**
* A handler ??? iterator
*
namespace Hub\Iterator\Handler\Pool;
// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
use CoreFramework\Lists\Listable;
+// Import SPL stuff
+use \Iterator;
+
/**
* A HandlerPool iterator
*
namespace Hub\Iterator\Pool\Monitor;
// Import framework stuff
-use CoreFramework\Registry\Registerable;
+use CoreFramework\Iterator\BaseIterator;
use CoreFramework\Lists\Listable;
+use CoreFramework\Registry\Registerable;
+
+// Import SPL stuff
+use \Iterator;
/**
* A MonitorPool iterator
<?php
+// Own namespace
+namespace Hub\Iterator\Shutdown\;
+
+// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
+
+// Import SPL stuff
+use \Iterator;
+
/**
* A shutdown ??? iterator
*
<?php
// Own namespace
-namespace Hub\Iterator\Pool\Shutdown;
+namespace Hub\Iterator\Shutdown\Pool;
// Import framework stuff
+use CoreFramework\Iterator\BaseIterator;
use CoreFramework\Lists\Listable;
+// Import SPL stuff
+use \Iterator;
+
/**
* A ShutdownPool iterator
*
use CoreFramework\Lists\Listable;
use CoreFramework\Registry\Registerable;
+// Import SPL stuff
+use \Iterator;
+
/**
* A TaskPool iterator
*
// Own namespace
namespace Hub\Iterator\Producer\TestUnitKey;
-// Import Framework stuff
+// Import framework stuff
use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Iterator\BaseIterator;
+
+// Import SPL stuff
+use \Iterator;
/**
* A TestUnitKeyProducer iterator
$this->partialStub('Need to implement this method.') {
}
- /**
- * Getter for connection type
- *
- * @return $connectionType Connection type for this listener
- */
- public function getConnectionType () {
- $this->partialStub('Need to implement this method.') {
- }
-
}
*/
private $listenPort = 0; // This port MUST be changed by your application
- /**
- * Whether we are in blocking or non-blocking mode (default: non-blocking
- */
- private $blockingMode = false;
-
/**
* A peer pool instance
*/
$this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry));
}
- /**
- * Setter for blocking-mode
- *
- * @param $blockingMode Whether blocking-mode is disabled (default) or enabled
- * @return void
- */
- protected final function setBlockingMode ($blockingMode) {
- $this->blockingMode = (boolean) $blockingMode;
- }
-
- /**
- * Checks whether blocking-mode is enabled or disabled
- *
- * @return $blockingMode Whether blocking mode is disabled or enabled
- */
- public final function isBlockingModeEnabled () {
- return $this->blockingMode;
- }
-
/**
* Setter for peer pool instance
*
return $this->poolInstance;
}
- /**
- * Getter for connection type
- *
- * @return $connectionType Connection type for this listener
- */
- public final function getConnectionType () {
- // Wrap the real getter
- return $this->getProtocolName();
- }
-
/**
* Registeres the given socket resource for "this" listener instance. This
* will be done in a seperate class to allow package writers to use it
return $this->getListenerInstance()->getListenPort();
}
- /**
- * Getter for connection type
- *
- * @return $connectionType Connection type for this listener
- */
- public final function getConnectionType () {
- return $this->getListenerInstance()->getConnectionType();
- }
-
/**
* Accepts the visitor to process the visit "request"
*
use CoreFramework\Visitor\Visitable;
use CoreFramework\Visitor\Visitor;
+// Import SPL stuff
+use \Iterator;
+
/**
* A NetworkPackage class. This class implements Deliverable and Receivable
* because all network packages should be deliverable to other nodes and
*/
public function getRegisteredSocketResource (Listenable $listenerInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getConnectionType() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ' - CALLED!');
// The socket must be registered before we can return it
if (!$this->isInfoRegistered($listenerInstance)) {
$socketInstance = $registryInstance->getInstance($socketKey);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getConnectionType() . ',socketResource[]=' . gettype($socketInstance) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ',socketResource[]=' . gettype($socketInstance) . ' - EXIT!');
// Return the resource
return $socketInstance;
$cfg->setConfigEntry('socket_file_decorator_listener_class', 'Hub\Listener\Socket\SocketFileListenerDecorator');
// CFG: NODE-TCP-LISTENER-CLASS
-$cfg->setConfigEntry('node_tcp_listener_class', 'HubTcpListenerDecorator');
+$cfg->setConfigEntry('node_tcp_listener_class', 'Hub\Listener\Hub\Tcp\HubTcpListenerDecorator');
// CFG: NODE-UDP-LISTENER-CLASS
-$cfg->setConfigEntry('node_udp_listener_class', 'HubUdpListenerDecorator');
+$cfg->setConfigEntry('node_udp_listener_class', 'Hub\Listener\Hub\Udp\HubUdpListenerDecorator');
// CFG: CLIENT-TCP-LISTENER-CLASS
-$cfg->setConfigEntry('client_tcp_listener_class', 'ClientTcpListenerDecorator');
+$cfg->setConfigEntry('client_tcp_listener_class', 'Hub\Listener\Client\Tcp\ClientTcpListenerDecorator');
// CFG: CLIENT-UDP-LISTENER-CLASS
-$cfg->setConfigEntry('client_udp_listener_class', 'ClientUdpListenerDecorator');
+$cfg->setConfigEntry('client_udp_listener_class', 'Hub\Listener\Client\Udp\ClientUdpListenerDecorator');
// CFG: NODE-POOL-CLASS
$cfg->setConfigEntry('node_pool_class', 'Hub\Pool\Peer\DefaultPeerPool');
$cfg->setConfigEntry('handler_pool_iterator_class', 'HandlerPoolIterator');
// CFG: NETWORK-LISTEN-ITERATOR-CLASS
-$cfg->setConfigEntry('network_listen_iterator_class', 'NetworkListenIterator');
+$cfg->setConfigEntry('network_listen_iterator_class', 'Hub\Iterator\Network\Listener\NetworkListenIterator');
// CFG: SOCKET-LISTEN-ITERATOR-CLASS
$cfg->setConfigEntry('socket_listen_iterator_class', 'CoreFramework\Iterator\DefaultIterator');
// CFG: TCP-RAW-DATA-HANDLER-CLASS
-$cfg->setConfigEntry('tcp_raw_data_handler_class', 'TcpRawDataHandler');
+$cfg->setConfigEntry('tcp_raw_data_handler_class', 'Hub\Handler\Network\RawData\Tcp\TcpRawDataHandler');
// CFG: UDP-RAW-DATA-HANDLER-CLASS
-$cfg->setConfigEntry('udp_raw_data_handler_class', 'UdpRawDataHandler');
+$cfg->setConfigEntry('udp_raw_data_handler_class', 'Hub\Handler\Network\RawData\Udp\UdpRawDataHandler');
// CFG: SOCKET-RAW-DATA-HANDLER-CLASS
$cfg->setConfigEntry('socket_raw_data_handler_class', 'Hub\Handler\Network\Socket\RawData\SocketRawDataHandler');
* @return $result Result from listening on socket
* @throws InvalidSocketException If stored socket is invalid
*/
- function listenOnSocket ();
+ function listenToSocket ();
/**
* Tries to set non-blocking I/O on stored socket
*/
function enableSocketNonBlocking ();
+ /**
+ * Tries to enable option "reuse address"
+ *
+ * @return void
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ function enableSocketReuseAddress ();
+
/**
* Some "getter" for peer address/port from stored socket
*
*/
function getConnectionPort ();
- /**
- * Getter for connection type
- *
- * @return $type Type of connection
- */
- function getConnectionType ();
-
/**
* Getter for IP address
*
* @return $shuttedDown Whether this connection is shutted down
*/
function isShuttedDown ();
-}
-// [EOF]
-?>
+}
* @return $iteratorInstance An instance of a Iterator class
*/
function getKeyIterator ();
-}
-// [EOF]
-?>
+}
*/
function getListenPort ();
- /**
- * Getter for connection type
- *
- * @return $connectionType Connection type for this listener
- */
- function getConnectionType ();
-
/**
* Getter for peer pool instance
*