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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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.