// Add it to the peers
$this->getPoolInstance()->addPeer($newSocket);
+
+ // Get peer name
+ if (!socket_getpeername($newSocket, $peerName)) {
+ // Handle this socket error with a faked recipientData array
+ $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0'));
+ } // END - if
+
+ // Create a faked package data array
+ $packageData = array(
+ NetworkPackage::PACKAGE_DATA_SENDER => $peerName . ':0',
+ NetworkPackage::PACKAGE_DATA_RECIPIENT => $this->getSessionId(),
+ NetworkPackage::PACKAGE_DATA_PROTOCOL => $this->getProtocol(),
+ NetworkPackage::PACKAGE_DATA_STATUS => NetworkPackage::PACKAGE_STATUS_FAKED
+ );
+
+ // Get a socket registry
+ $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
+
+ // Register the socket with the registry and with the faked array
+ $registryInstance->registerSocket($this, $newSocket, $packageData);
} // END - if
// Do we have to rewind?
// Debug message
$this->debugOutput('POOL: Adding peer ' . $peerName . ',socketResource=' . $socketResource);
- // Create the fake array
- $packageData = array(
- NetworkPackage::PACKAGE_DATA_SENDER => $peerName . ':0',
- NetworkPackage::PACKAGE_DATA_RECIPIENT => $this->getSessionId(),
- NetworkPackage::PACKAGE_DATA_PROTOCOL => $this->getListenerInstance()->getProtocol(),
- NetworkPackage::PACKAGE_DATA_STATUS => NetworkPackage::PACKAGE_STATUS_FAKED
- );
-
- // Get a socket registry
- $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
-
- // Register the socket with the registry and with a half-fake array
- $registryInstance->registerSocket($this->getListenerInstance(), $socketResource, $packageData);
-
// Add it finally to the pool
$this->addPoolEntry($socketResource);
}