Jump to content

Persistent socket connection


Asheeown

Recommended Posts

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

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.

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);
}

?>

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.

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.