Asheeown Posted May 4, 2008 Share Posted May 4, 2008 Okay let me start off by saying what I am trying to accomplish here. I am building a website to monitor a program that offers a socket connection and a list of commands to operate the program remotely. The program offers many informational commands that tells the status of what's going on. It also offers a log command which is what brings me to this. In my program I start up my connection to the program and enter in my password...if all is well, continue. $fp = @fsockopen($url, $port, $errno, $errstr, 5); if (!$fp) { die("Unable to connect: $errstr (Error: $errno))"; } fwrite($fp, $pass . "\r\n"); I enter in a status command and extract the information from it: // Write Status Command fwrite($fp, "/status\r\n"); // Open new array $lines = array(); //Distinguish status information from other information while (!feof($fp) && $str = trim(fgets($fp))) { if ($str == "---") break; $lines[] = $str; } // Open the information array $info = array(); // Load the information array foreach ($lines as $v) { if (preg_match('/^([^:]+):\s*(.+)\s*$/', $v, $reg)) { $info[$reg[1]] = $reg[2]; } } Everything is PERFECT, the status of the program is posted in front of the user...now here is the tricky part The command to log all information, which I would like to use, is "/log all". Now when that command is initiated all logged information is posted in the socket connection window (I tried this with a windows telnet client and saw all of it). The goal I am trying to accomplish is to get that information asynchronously as to not kill the socket connection. Any ideas? If anymore explanation is required just let me know. Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/ Share on other sites More sharing options...
Asheeown Posted May 5, 2008 Author Share Posted May 5, 2008 I know it has something to do with asynchronous socket connections and I know it can be done, I just need guidance on how Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533162 Share on other sites More sharing options...
Asheeown Posted May 5, 2008 Author Share Posted May 5, 2008 Please, anyone have any suggestions? Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533317 Share on other sites More sharing options...
Asheeown Posted May 5, 2008 Author Share Posted May 5, 2008 BUMP Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533896 Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 I'm really not sure if you can do that in PHP because each request is seperate from other requests, so in order to get the response from the program (presumably through AJAX and another PHP page), you'd need a new connection in the other script. Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533912 Share on other sites More sharing options...
Asheeown Posted May 5, 2008 Author Share Posted May 5, 2008 Yeah see that's where I get stuck because is their a way to keep a connection open to another page instead of just asynchronously calling a new instance of that page? Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533964 Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 Not that I know of. Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-533972 Share on other sites More sharing options...
Asheeown Posted May 6, 2008 Author Share Posted May 6, 2008 I see that whenever it registers a new socket connection it assigns the remote connection a new port up in the high 10,000's, is their anyway to like save the connection on the port and then resume it on next reload? Link to comment https://forums.phpfreaks.com/topic/104125-socket-connection-help/#findComment-534022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.