I have simple server that is listening to port 5000. The server is running normally and when a browser sends an http request, then the server is able to read what the browser has sent.

The problem is that I cannot figure out how the server should reply to the browser. Actually, the server is able to reply to a telnet client. Here the problem is that the server replies every time a character is entered in the telnet window.

Back to the problem... how can the server know when to write to the browser, and how ?