in reply to My first socket program is SLOW?
If the page you're fetching is largish, reading it in 100 byte chunks and building it up by repeated concatentation:
while ($data) { recv(SK_CLIENT, $data, 100, 0); $thePage .= $data; }
could be a part of your problem. Something like
1 while read( SK_CLIENT, $thePage, 4096, length( $thePage ) );
might run a little more quickly.
Better still might be to read the first few lines of the response line by line and look for the Content-length header, and then read the rest in one go.
|
|---|