Sorry, didn't realise you already knew that.
I don't write PHP, i'm a perl person.
There is a dedicated module in perl, so theres probabally one for php.
Here's a simple method.
$server = fsockopen($host, $port);
This will return the first 1K of data. That should contain a header.
I think $frombrowser should be the file you are requesting maybe?? GET /file.html HTTP/1.1
This is just out of some code that i've got lying around. Not my code mind