Jump to content


Some help with client socket

  • Please log in to reply
2 replies to this topic

#1 Muggins



  • New Members
  • Pip
  • 6 posts

Posted 16 March 2014 - 03:47 PM


Out of my depth here:

I have some automation running on a hacked livebox.

I want to socket connect, then send an instruction. Problem is the response is constantly changing and I need to somehow requery and parse the result at intervals like 5 seconds. Just beginning to learn PHP so be kind if there is an easy answer. Here is some cut down script.


switch ($_REQUEST['btn_submit'])
case "Liv Boost":
$response = send("boost liv 1");
case "Liv OFF":
$response = send("boost liv 0");
case "Requery":
$response = send("");
function send($sendstring)
$fp = fsockopen("xx.xx.xx.xx", 9996, $errno, $errstr, 10);
    fwrite($fp, $sendstring);  
return fread($fp, 2056);
function parse($RD,$par1,$par2,$par3)
If ($pos > 0){return substr($RD, $pos + $par2 , $par3);}
<head id="Head1" runat="server">
  <title>Home Automation</title>
<form method="POST">
<input type="submit" name="btn_submit"  value="Liv Boost" />
<input type="submit" name="btn_submit"  value="Liv OFF" />
<input type="textbox" name="rowID"  value="<?php echo parse($response,"livboostcounter",46,5); ?>" /></br>
<input type="submit" name="btn_submit" value="Requery" />

#2 trq


    Advanced Member

  • Administrators
  • 31,036 posts
  • LocationSydney, Australia.

Posted 16 March 2014 - 04:59 PM

Do you have a question?

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.

#3 Muggins



  • New Members
  • Pip
  • 6 posts

Posted 17 March 2014 - 04:36 AM

My question was how do I send the requery at intervals, or perhaps there is a better way to do it.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime