[cs631apue] Handling telnet vs nc/browsers

Jan Schaumann jschauma at stevens.edu
Fri Nov 22 22:52:03 EST 2013


Tejas Nadkarni <tnadkarn at stevens.edu> wrote:
 
> Any ideas from others how to work around this? Would it make sense to
> detect the client connecting to the socket and change behavior
> appropriately?

No, you should not change the behaviour based on the client connecting.

Make sure to read all available input from the client up until you see
two CRLF in succession.  If reading from the socket only yields a single
line (ie text with just one CRLF), then your process should continue
reading (and thus block) until the final CRLF is delivered (or the
request is timed out).

-Jan


More information about the cs631apue mailing list