By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

Problem reading files from sockets...

P: n/a
Hey there. I have a small problem with sockets. The code is really
simple, but it still fails.

The problem is I am accessing a .rar file (for those who don't know
it's an archive, like .zip) through fsockopen and I'm only getting the
headers... The file is not coming.

# Open the host
$fp = fsockopen($url['host'], 80, $errno, $errstr, 30);
# Ask for the file. $method is GET and $GET is the path and filename
of the file (files/eye.rar).
$out = $method.' '.$GET.' HTTP/1.0

# I also send HOST header properly
# and user agent

# Send a blank line to indicate end of headers
$out .= '

fwrite($fp, $out);
$buffer = fread($fp, 4000000);
print $buffer;

The result is:

HTTP/1.1 200 OK
Date: Mon, 11 Feb 2008 14:25:48 GMT
Connection: close
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Disposition: Attachment; filename=eye.rar
Content-Length: 466159

I should have gotten the headers + a part of the file. Why didn't I?

Can anyone help me, please?
Feb 11 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.