Re: Getting a string from a file or socket
Joachim Ziegler <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Message-ID | <[email protected]> |
Hello Julien, > One of the reasons for this not being included in NSPR may be that the > EOL characters are platform-specific. Now that I try to run my client/server code under Unix *and* Windows, I see what you mean. :-) Yes, I really have to write my own version of fgets() that is able to handle both cases of LF *and* CR+LF being used as the newline indicator. I guess this has been done a thousand times before, so I would like to see it in a "repository of useful code snippets" or so. It is really annoying to have to do this myself. There are so many tiny little special cases. For example, what if I encounter a CR? Can I rely on the client also sending a LF as the next character? (I guess this should be part of the protocol). What if the CR happens to be the last character of the the buffer? What if the connection is closed after the CR? And so on. But I am surely able to do this. Joachim