fsockopen
| From: | Chris Allen | Date: | Fri, 28 Sep 2001 18:04:16 +0000 |
| Subject: | fsockopen | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-69200@lists.php.net to get a copy of this message | ||
Phpers:
I cannot for the life of me get this bit of code to work! The server on the
other end is echoing back what ever I send to it and when I telnet to it.
It correctly echos back whatever I type... The server correctly gets
"TESTING1111", but I cannot get its response in $res.
It is stuck in an infinite loop with $res = nothing. then MAX_execution time
is reached.
By adding socket_set_timeout I get it to pass off the data stored in
$message but nothing gets placed in $res from the fgets() call...
Any clue as to how to force data to be placed into $res? I have experimented
with blocking to both true and false and also
dumping socket status this is what I get :
array(4) { ["timed_out"]=> bool(false) ["blocked"]=> bool(true)
["eof"]=>
bool(false) ["unread_bytes"]=> int(0) } Res is
I have also had the server send /n (03) and /r/n but that didnt seem to
help.....
The code:
$fp = fsockopen ("x.x.x.x", 65000 , $errno, $errstr, 50) or die ("Connection
failed");
$message = "TESTING11111";
fputs($fp,"$message");
$start = time();
socket_set_timeout($fp,5);
while(!feof($fp)) {
$res .= fgets($fp, 4096);
echo "Res is $res <br>";
}
echo "$res";
Thanks,
Christopher C. M. Allen
1-715-821-4006
callen@nocpop.net