Reputation: 6078
I have to develop a multiple users chat application (like msn). I don't what to use any framework to build it because I want to learn how those things work.
I am developing it in Delphi or C# but it does not really matter. What matter is that the chat client is going to be an app, not a browser.
The question is: what is the best way of handling messages between the clients?
So far, I know those techniques:
Pushlet
Polling
Long polling
Link to the Wikipedia
Upvotes: 1
Views: 987
Reputation: 36634
Do you need to support (tens of) thousands of simultanous connections? If yes, I recommend to take a look at
which are used in application servers and standards like Servlet 3.0 to minimize the number of worker threads and speed up network operation
There is a IOCP library for Delphi - see Is there a I/O completion port based component for Delphi?
Also HTTP could be used as the internal protocol, the new Microsoft http.sys library provides a great foundation and is included with new versions of Windows.
To give an impression how efficient messaging servers can be: on relatively modest hardware, the open source ActiveMQ Apollo server can handle 1.2 million messages per second. (It is written in Java)
Upvotes: 2
Reputation: 116100
It looks like all of these are particulary useful for HTTP, since HTTP doesn't really allow connections to be permanently open. This is the way to go if you're writing a web based chat client that use Ajax (or REST calls anyway).
If you're writing a chat application (either P2P or client/server) yourself, you can create a connection that stays open permanently.
So, the server just listens on a given port. The client tries to connect to that port on the server's IP address. If the connection succeeds, it stays open until the client user closes the program (if all goes well).
Delphi does have a chat application demo that uses the Indy TCP components. You can take a sneak peak there, even if you're going to build it yourself afterwards.
Upvotes: 3