The PHP function fsockopen initiates a stream connection
to another machine across a network. When you use this to communicate with
another machine, use the simpler HTTP 1.0 protocol unless you specifically
need some of the features provided by the HTTP 1.1 protocol.
With HTTP 1.1, the default behavior is to keep connections alive until
they are explicitly closed or the connection times out. This behavior can create some
serious performance consequences if clients that don't expect, or utilize
the behavior. (Note that for clients designed with this behavior
in mind, keeping connections alive actually improves performance.)
Unless your application requires that connections be kept alive, then
seriously consider using the HTTP 1.0 protocol with
fsockopen, as in the sample code below:
$fp = fsockopen( $server, $port );
fputs($fp, "GET $page HTTP/1.0\r\nHost: $server\r\n\r\n");
When using the HTTP 1.1 protocol to make a request to another machine,
you may also encounter unexpected hex values
interspersed amongst the returned data. These unexpected hex
values are the result of a chunked transfer-encoding which,
according to the HTTP 1.1 specifications must be supported by any HTTP 1.1
application. Therefore, your application should either handle
this type of encoding, or not claim to be an HTTP 1.1 client.
So, in summary, claim to be an HTTP 1.0 client unless you specifically
need features of the HTTP 1.1 protocol. If you do need HTTP 1.1 features,
then be sure to support the newer protocol fully.