|
Posted by NC on 03/17/06 20:10
Arnaud wrote:
> "NC" <nc@iname.com> a écrit dans le message de news:
> 1142613530.709211.49000@z34g2000cwc.googlegroups.com...
>
> > What exactly did you try and what kind of "no result" have you achieved
> > (error messages, etc.)?
>
> if ($handle = fsockopen('https://myserver:4012/code/param?', 80, $errno,
> $errstr))...
> or
> if ($handle = fsockopen('https://myserver:4012/code/param?', 4012, $errno,
> $errstr))...
> or
> if ($handle = fsockopen('https://myserver/code/param?', 4012, $errno,
> $errstr))...
But of course it didn't work... Have you even looked at fsockopen()
documentation? Check it out:
http://www.php.net/fsockopen
The correct usage of fsockopen() in your case would be something like
this:
$host = 'myserver';
$port = 4012;
$path = 'code/myapp?param1=3';
$fp = fsockopen($host, $port, $errno, $errstr);
if ($fp) {
fputs($fp, "GET $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n\r\n");
} else {
die ("Could not connect to $host on port $port: error $errno
($errstr)");
}
$data = '';
while (!feof ($fp)) {
$data .= fgets ($fp, 10240);
}
fclose ($fp);
Now $data should contain the entire HTTP response, including HTTP
headers...
Cheers,
NC
Navigation:
[Reply to this message]
|