Asheeown Posted June 9, 2008 Share Posted June 9, 2008 I am trying to hold a pfsocks connection in a session variable, some say it can be done but how is the question. Does anyone know where any examples of successful attempts at this are. Or can someone explain how to successfully get it into a variable that can be used over again. It populates the variable at first but when the page is refreshed the session var turns to "0" Any feedback would be great, thanks! Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/ Share on other sites More sharing options...
DarkWater Posted June 9, 2008 Share Posted June 9, 2008 I'm pretty sure that you can't have a persistent socket connection in PHP last over multiple pages because of the nature of HTTP. I could be wrong though. >_> Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561536 Share on other sites More sharing options...
trq Posted June 9, 2008 Share Posted June 9, 2008 Resources cannot be stored within a session. Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561538 Share on other sites More sharing options...
Asheeown Posted June 9, 2008 Author Share Posted June 9, 2008 Then is there another way of accomplishing what I want to do? I am connecting to a program with fsocks on a certain port with an ip and I need it to stay open for a certain function the program offers, it's a log function that logs text over the period of time connected to the program so in that case I need to hold the connection and also keep shelling out the information that comes in about every 30 seconds. Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561543 Share on other sites More sharing options...
trq Posted June 9, 2008 Share Posted June 9, 2008 You'll want to place your program into an infinite loop, hence, this shouldn't type of script shouldn't be executed via apache but the command line interface. <?php if ($fp = fsockopen("192.168.10.1", 1975, $errnum, $err, 10)) { while (!feof($fp)) { echo fgets($fp); } fclose($fp); } ?> Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561549 Share on other sites More sharing options...
Asheeown Posted June 9, 2008 Author Share Posted June 9, 2008 Okay so say I use that page to be executed server side when the user connects to view the page, how will I reload the apache side script and keep the server side one running? Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561557 Share on other sites More sharing options...
Asheeown Posted June 10, 2008 Author Share Posted June 10, 2008 I've looked into it, it doesn't seem like it can be done, holding the socket connection on a server-side script and accessing it via apache to return the results. Is their any other way the storing of a socket resource can be done or any other language it can be done in? BUMP. Link to comment https://forums.phpfreaks.com/topic/109473-persistent-socket-connection/#findComment-561721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.