// Validate the socket
$this->validateSocket($socketResource);
+ // Default is this peer's IP
+ $peerName = '0.0.0.0';
+
+ // The socket resource should not match server socket
+ if ($socketResource != $this->getListenerInstance()->getSocketResource()) {
+ // Try to determine the peer's IP number
+ if (!socket_getpeername($socketResource, $peerName)) {
+ // Get last error
+ $lastError = socket_last_error($socketResource);
+
+ // Doesn't work!
+ throw new InvalidSocketException(array($this, gettype($socketResource), $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+ } else {
+ // Server sockets won't work with socket_getpeername()
+ $this->debugOutput('POOL: Socket resource is server socket. This is no bug.');
+ }
+
// Output error message
- $this->debugOutput('POOL: Adding client ' . $socketResource);
+ $this->debugOutput('POOL: Adding client ' . $peerName);
// Add it finally to the pool
$this->addPoolEntry($socketResource);