note 5367 rejected from function.pfsockopen by didou

From: Date: Wed, 21 May 2003 21:42:10 +0000
Subject: note 5367 rejected from function.pfsockopen by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-48786@lists.php.net to get a copy of this message
Note Submitter: jonathan@sharpmedia.net ---- RE: Above note, yes it will open a new connection and return a different id if you don't have your script check to see if there's already a connection. Use the following code: <pre> /* Check to see if a connection is already open */ if(!isset($mysocket)){ $mysocket = pfsockopen("myhost.com", "80", '', '', "60"); } else{ fputs($mysocket,"GET / HTTP/1.0\n\n"); while(!feof($mysocket)) { echo fgets($mysocket,128); } fclose($mysocket); } /* Make sure to include $mysocket when calling this script */ echo "<input type=\"hidden\" name=\"mysocket\" value=\"$mysocket\">"; /* or use */ echo "<a href=\"$PHP_SELF?mysocket=$mysocket\">Do Foo</a>";

« previous php.notes (#48786) next »