Jump to content

PHP socket multiple source file


Ronen

Recommended Posts

Hi Everyone,

 

I'm trying to have the first file open the socket and then call another file to proceed with diff. things. BUT i lose the socket pointer (resource) once I load the second file.

 

any ideas, please help thank you.

 

 

here is the code:

 

<?php
session_start();
 
$fp = stream_socket_client("udp://127.0.0.1:5003", $errno, $errstr);
$_SESSION['fp'] = $fp;
 
if (!$fp) { 
    echo "ERROR: $errno - $errstr<br />\n";
} else {
for ($i=1;$i<2;$i++){
callme($fp,$i);
}
   header ("refresh:0;url=client7b.php" );
 
}
fclose($fp);
 
function callme($fp,$x)
{
fwrite($fp, $x);
//echo fread($fp, 26);
 
}
?>
 
Ronen
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.