note 13226 deleted from function.connect by nlopess

From: Date: Sat, 26 Jun 2004 11:37:15 +0000
Subject: note 13226 deleted from function.connect by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71747@lists.php.net to get a copy of this message
Note Submitter: kmurray@insight.com ---- Be VERY careful when using this function. When performing multiple connection attempts, be sure to obtain a new socket descriptor before each call to connect(). Failing to do so may cause a kernel panic or complete lockup. When this happens the OS requires me to reboot, fsck, and repair on a few partitions. I can duplicate this behavior on 4.0.4pl1 consistently. BAD EXAMPLE: $this->sockd = socket(AF_INET, SOCK_STREAM, 0); if ( $this->sockd < 0 ) { print "ERROR: Could not obtain socket descriptor."; } else { print "SUCCESS: We have a socket descriptor."; for ( $rt = 0; $rt < $this->server_connect_retries; $rt++ ) { $stat = connect($this->sockd, $this->srv_ip_address, $this->server_port); if ( $stat < 0 ) { print "ERROR: Could not connect."; continue; } else { print "SUCCESS: Connected on socket."; break; } } } GOOD EXAMPLE: for ( $rt = 0; $rt < $this->server_connect_retries; $rt++ ) { $this->sockd = socket(AF_INET, SOCK_STREAM, 0); if ( $this->sockd < 0 ) { print "ERROR: Could not obtain socket descriptor."; continue; } else { print "SUCCESS: We have a socket descriptor."; $stat = connect($this->sockd, $this->srv_ip_address, $this->server_port); if ( $stat < 0 ) { print "ERROR: Could not connect."; continue; } else { print "SUCCESS: Connected on socket."; break; } } }

« previous php.notes (#71747) next »