Re: Large Scale Chat Program
Well, one idea might be to have each room run as a separate process.
People might connect to your Lobby process. Then when they choose a chat room, the Lobby checks to see if the chat room is running, starting it if need be. Then the Lobby could send the chat client a message telling it where to connect to. The client would disconnect from the Lobby, and connect to the IP & port contained in the redirection message.
Each chat room would communicate back to the Lobby process every time a user enters or leaves, allowing the Lobby to have the user count. When users drop to 0 the chat room could terminate.
The chat room process could be implemented as a standard EXE or as an ActiveX EXE. The latter offers an obvious communication path back to the Lobby via events or callbacks. A standard EXE could be communicated with via message passing, or mailslots, or anonymous pipes, another TCP connection, or whatever.
Ideally the Lobby would just "hand off" the client connection to the chat room process. These socket connections can't be passed between processes though.
Re: Large Scale Chat Program
The way I setup the lobbies and rooms seems decent but they are not on different exes or connections. I debated passing all commands through one connection and chat through the other. I also have another question, is tcp well suited for chat apps? Or is it better to do the proper handling and use udp instead?
Re: Large Scale Chat Program
Most chat systems I have seen use TCP. This is probably because of the limitations inherent in UDP, such as the fact that UDP datagrams can be dropped by any router anywhere in the Internet if it's "too busy."
Streaming media often use UDP because it has less latency, and for something like an audio stream a lost datagram isn't catastrophic.
My (maybe wacky) idea about separate EXEs was meant as a possible way to balance out the load. In reality though it probably only improves things if you use a multi-CPU/multi-core system or even multiple computers. It would add the nasty complication of requiring more ports to be used too: one for the Lobby, and a unique port for each chat room running on the same computer.
Re: Large Scale Chat Program
Ok, I appreciate all the feedback. One more small question however. I decided it would at lease be beneficial to split my chat and commands into separate sockets. I did this, and I noticed a strange bug:
When I connect, my commandsocket sends a message to the server's commandsocket. Everything works fine, and the user connects. Then, when I try to type. My first chat message, no matter how long I wait, always contains the information from my connect message. They are on totally different sockets....
I even tried to turn off SocketDelay and Adjust the SendBuffer size. No changes what so ever. It would seem as if my buffers needed to be "flushed." Any ideas?
Re: Large Scale Chat Program
Any ideas? This is really stumping me. And in every way makes 0 sense. My first message is always left overs of my command string.