I already wrote here about the http chat server I want to create: Alternative http port? This HTTP server must transmit text to each user in the same chat room on the website. The browser will remain connected and wait for further html code. (yes, that works, the browser will not reject the connection).
I had a new question: since this chat server does not need to receive information from the client, there is no need to listen to the client after the server has sent its first response. New chat messages will be sent to the server on a new connection. Therefore, I can open 2 streams, one for waiting for new clients (or new messages) and one for streaming html. Is this a good idea or should I use one thread per client? I donโt think itโs good to have one thread / client when there are many chat users on the Internet, since the server has to handle several different chats with their own rooms.
3 possibilities: 1. One stream for all clients, send text to each client in a row - there should not be much lag, since this is only text it will look like this: user1.send ("text"), user2.send ("text") , ... 2. One thread per chat or chat 3. One thread for the chat user -... many ...
Thanks, I havenโt done much with sockets yet;).
source share