slow reading from socket

This is a discussion on slow reading from socket within the PHP Language forums, part of the PHP Programming Forums category; I am writing a script that connects to somekind of telnet server, and returns the answers the server gives. Everything ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-18-2003
Wim Smit
 
Posts: n/a
Default slow reading from socket

I am writing a script that connects to somekind of telnet server, and
returns the answers the server gives.

Everything works fine until I have to start writing a loop. I want to give a
command which will give an answer of more than 1 line, but I do not know how
many lines it will be in total.



So I wrote something like this:

// get the list

fputs ($fp, "list all\n");

$list = "1";

while (!$list=="") {

$list = fgets($fp, 50);

echo "$list<BR>";

}



I tried also a few other loops like "while ($i < 100) or while(!feof) etc.
but they take over 40 seconds to show 4 lines of text.



But if I would do something like:

fputs ($fp, "list all\n");

$line1 = fgets($fp, 50);

$line2 = fgets($fp, 50);

$line3 = fgets($fp, 50);

etc.



It is ready within a second. Anybody knows how I can speed this up? I
already tried other functions like fread, fpassthru, all worked, but as
evenly slow.



Who can help me out?



Thanks!

And apologies if this is a n00b question.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:11 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0