views:

321

answers:

7

Hi I would like to create a chat application(desktop-app) in c++, so which protocol i would need to study and implement. UDP(?)

Please provide me some good thoughts and advices and links also.

A: 

You can use or look at an open-source networking library like ACE. A lot of goodies there.

Amit Kumar
A: 

You might want to look into Zeroconf for client discovery.

genpfault
A: 

You could use an existing library that handles instant messaging protocols, such as libpurple.

Graham Lee
+7  A: 

UDP protocol is not the best choice for Internet chat program. UDP packets will be blocked by proxies. And UDP doesn't guarantee packets delivery. So probably TCP protocol will be a better choice.

Take a look on Boost.Asio Library. It already contains primitive implementation of chat program.

Kirill V. Lyadvinsky
+1 for TCP and I would give another +1 for Boost.Asio (and especially its tcpstreams).
Tronic
I found asio to be poorly documented, not well supported, and difficult to understand even for an experienced programmer. I would not recommend it.
Jay
+1  A: 

Try using Boost.Asio. There are some examples of chat applications included in documentation.

Goxa
+3  A: 

You don't give us much details here!

If your purpose is really to make a fully working and feature full chat application I suggest you look at XMPP which is an open instant-messenging protocol. Here is a list of some libraries implementing it.

If your purpose is to study network programming and you're more interested in UDP versus TCP for instance, then UDP is a bad choice for a chat application as it does not guarantee much about data integrity or ordering. Your messages might (and will!) be received in bad order or some might even be missing. TCP does that for kind of check for you.

In between (a very simple chat app) you can implement your very own protocol and use libraries others have suggested here like Boost.asio, ACE, POCO, or even wxWidgets and Qt, which will ease socket handling and also provide what you need to build a desktop app for the last 2.

f4
A: 

UDP is like a 'shoot and forget' kind of protocol. It's fast, but if you use it for communicating over the internet, there's no guarantee your messages will be recieved at all. Even if it's LAN, your packets can still be lost. It would be more convenient to use TCP which makes sure your packets arrive without errors and in the order you sent them.

tiftik