 <p>It doesn't make sense to read the input until EOS and then expect to be able to write a response back to the same connection.</p> <p>You haven't actually written anything like an 'simple HTTP server yet. You need to study the HTTP RFC, in particular the part about content-length of requests. They are delimited by length, not by end of stream.</p>