Ronen Posted November 16, 2017 Share Posted November 16, 2017 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted November 16, 2017 Share Posted November 16, 2017 Don't use a second file. Put the code in the first one. Quote Link to comment Share on other sites More sharing options...
Ronen Posted November 16, 2017 Author Share Posted November 16, 2017 lol @ requinix. I know that in the same file it works. But I would like to know if it's possible and I'm sure it is to have it in a diff. file. Thank you Quote Link to comment Share on other sites More sharing options...
requinix Posted November 16, 2017 Share Posted November 16, 2017 You cannot share a socket across two separate web requests. Quote Link to comment Share on other sites More sharing options...
Ronen Posted November 17, 2017 Author Share Posted November 17, 2017 Thank you @Admin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.