// Default is no socket
$socketResource = false;
+ // Temporary resolve recipient field
+ $recipientIpArray = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+
+ // Make sure it is a valid ip:port array (2 elements)
+ assert(count($recipientIpArray) == 2);
+
// Debug message
- /* DEBUG: */ $this->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s) ...');
+ /* NOISY-DEBUG: */ $this->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s), recipientIpArray[0]=' . $recipientIpArray[0] . ' ...');
// Get all sockets and check them, skip the server socket
foreach ($this->getAllSockets() as $socket) {
// Is this a server socket?
if ($socket === $this->getListenerInstance()->getSocketResource()) {
// Skip 'server' sockets (local socket)
+ /* NOISY-DEBUG: */ $this->debugOutput('POOL: Skipping local socket ' . $socket . ' ...');
continue;
} // END - if
- // @TODO Check for IP
- $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: '.print_r($packageData, true));
+ // Try to get the "peer"'s name
+ if (!@socket_getpeername($socket, $peerIp)) {
+ // Handle the socket error with given package data
+ $this->handleSocketError($socket, explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+ } // END - if
+
+ // If the "peer" IP and recipient is same, use it
+ if ($peerIp == $recipientIpArray[0]) {
+ // IPs match, so take the socket and quit this loop
+ $socketResource = $socket;
+
+ // Debug message
+ /* NOISY-DEBUG: */ $this->debugOutput('POOL: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socket);
+ break;
+ } // END - if
} // END - foreach
// Return the determined socket resource
+ /* NOISY-DEBUG: */ $this->debugOutput('POOL: socketResource[' . gettype($socketResource) . ']=' . $socketResource);
return $socketResource;
}
}
./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:38: * @todo We may want to implement a filter for ease notification of other objects like our pool
./application/hub/interfaces/helper/messages/class_MessageHelper.php:10: * @todo Please find another name for this interface
./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo We need to find a better name for this interface
-./application/hub/main/class_BaseHubSystem.php:300: // @TODO On some systems it is 134, on some 107?
+./application/hub/main/class_BaseHubSystem.php:323: // @TODO On some systems it is 134, on some 107?
./application/hub/main/commands/console/class_HubConsoleChatCommand.php:107: * @todo Should we add some more filters?
./application/hub/main/commands/console/class_HubConsoleChatCommand.php:58: * @todo Try to create a ChatActivationTask or so
./application/hub/main/commands/console/class_HubConsoleCruncherCommand.php:107: * @todo Should we add some more filters?
./application/hub/main/package/class_NetworkPackage.php:716: // @TODO Add some content here
./application/hub/main/package/class_NetworkPackage.php:766: * @todo This may be enchanced for outgoing packages?
./application/hub/main/package/fragmenter/class_PackageFragmenter.php:427: * @todo $helperInstance is unused
-./application/hub/main/pools/peer/class_DefaultPeerPool.php:160: // @TODO Check for IP
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106: // @TODO Do something with it
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:62: * @todo Find something for init phase of this key producer
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:72: * @todo ~30% done