Menu

urlStream vs readLine()

Help
Anonymous
2001-05-29
2001-05-31
  • Anonymous

    Anonymous - 2001-05-29

    I would like to understand the exact purpose of the method readline() vs a getLine(..) in the source code of UrlStream.  Since underflow is used it will be better to use the getline() from the stream ?

    I will understand if the readline(), of the socket class, will only peek to the socket buffer but It doesnt seem that way.

    thanks for the answer.

     
    • David Sugar

      David Sugar - 2001-05-30

      Readline works BELOW the level of the streaming mechanism.  It's a clever hack to directly process line oriented i/o without having to use any buffering.  The initial http headers are extracted with readline in URLStream.

       
    • Anonymous

      Anonymous - 2001-05-31

      I doesnt look that way since we inherited from a stream.  First the Readline() under WIN32 is not functional because the primitve read is used. Second, Win32 doesnt recommand to use a MSG_PEEK which is inefficient.

      if statuquo 
        peek 512 bytes into a buffer
        parse the buffer and find the line
        read again to get only the line into a buffer
        ..continue like this for 10 headers.

      using the getLine()
         recv the buffer into the stream buffer ONCE

         getline() from the stream buffer, for 10 times.

      but the statuquo is good if an error is reponsed, close the connection, tell the user of the API that an 404 file not found has been responsed and tell him that you cannot extract the message body.

      but if no error is responsed (most of the time on Get) the second solution is more efficient I believe.

      You are my judge. 

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.