422,952 Members | 2,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,952 IT Pros & Developers. It's quick & easy.

Php read socket stream/push data from local app

P: 1
I connect to an application that should give me a push/stream data.

With the following code I have a positive answer from the app (outcome=OK|item=THEITEM) but I can't figure out how to get the var "last_value" and its updates. The loop is commented out, I have no echo with it (infinite loop)
Expand|Select|Wrap|Line Numbers
  1. $port = ('5333');  
  2. $address = ('127.0.0.1');   
  3. $fp = stream_socket_client("tcp://$address:$port", $errno, $errstr, 1);  
  4. if (!$fp) {  
  5.         echo "$errstr ($errno)<br />\n";  
  6. } else {    
  7.         $in = "function=subscribe|item=THEITEM|schema=last_value";  
  8.         fwrite($fp, $in."\n");  
  9.         //while (!feof($fp)) {  
  10.                 echo fgets($fp, 1024);  
  11.         //}  
  12.         fclose($fp);  
  13. }  
  14.  
This returns outcome=OK|item=THEITEM. The updates (push/stream data) should be like THEITEM|last_value.

(mac osx 10.10, mamp)
May 19 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.