You are here: Re: Open a https url on a special port ? (asp/ajax inside) « PHP Programming Language « IT news, forums, messages
Re: Open a https url on a special port ? (asp/ajax inside)

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация