shakeelmscw
11-25-2011, 06:15 AM
I am totally new to php coding and also fsockopen command.
Through Telnet i am able to access my host at 192.168.0.150 10001(port)
Now i need to access the device(same host) through php fsockopen. i need to store the output to a variable and want to apply some calculation on that variable.
below is the coding i am using and error i am getting
<?php
$fp = fsockopen("192.168.0.150", 10001, $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: 192.168.0.150\r\n";
$out .= "Connection: Close\r\n\r\n";
echo $out;
echo $fp;
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
when i open this php file in my xampp local server i am getting below error.
Error message in browser
GET / HTTP/1.1 Host: 192.168.0.150 Connection: Close Resource id #22.60 2.59 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.59 2.59 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.59 2.60 2.59 2.59 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.59 2.60 2.60 2.59 2.60 2.60 2.59 2.60 2.60 2.60
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\c.php on line 13
mine data is a stream line and not saved in a file. Infect i need to read the data from my internal network device ip 192.168.0.150 port 10001
if i put 192.168.0.150:10001 in browser address bar i am receiving new value every .5 second. i need to sum all these values in a variable and also count the total values received in 30 seconds. so i will be able to get single average value by dividing the sum of values by count of values. Please help me what code should i use?
Through Telnet i am able to access my host at 192.168.0.150 10001(port)
Now i need to access the device(same host) through php fsockopen. i need to store the output to a variable and want to apply some calculation on that variable.
below is the coding i am using and error i am getting
<?php
$fp = fsockopen("192.168.0.150", 10001, $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: 192.168.0.150\r\n";
$out .= "Connection: Close\r\n\r\n";
echo $out;
echo $fp;
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
when i open this php file in my xampp local server i am getting below error.
Error message in browser
GET / HTTP/1.1 Host: 192.168.0.150 Connection: Close Resource id #22.60 2.59 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.59 2.59 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.59 2.60 2.59 2.59 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.60 2.59 2.60 2.60 2.59 2.60 2.60 2.60 2.60 2.59 2.60 2.59 2.59 2.60 2.60 2.59 2.60 2.60 2.59 2.60 2.60 2.60
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\c.php on line 13
mine data is a stream line and not saved in a file. Infect i need to read the data from my internal network device ip 192.168.0.150 port 10001
if i put 192.168.0.150:10001 in browser address bar i am receiving new value every .5 second. i need to sum all these values in a variable and also count the total values received in 30 seconds. so i will be able to get single average value by dividing the sum of values by count of values. Please help me what code should i use?