C/C++ Chat

Hello guys ,

I have quite a good grasp of C and C++ (Java as well) but I've never had to deal with networking before. I know the very basic like : what is a client/server/IP address , nothing more .

My aim is to make a program which can send text messages from a PC to another ("like" skype) on linux, if it all goes well I might encrypt data or add video streaming later.

Which of the languages above would make my task easier and why ?
Also could you please turn me in the right direction, where should I start off or how ?

Thank you!
PS : If anyone is interested and wants to join in please let me know.
I know the question is too general , any idea of yours is welcomed.
Last edited on
Which would be easiest? Java definitely. It has built in networking capabilities which are super simple to use. Start here: http://docs.oracle.com/javase/tutorial/networking/

If you go the C++ route, I reccomend Boost.Asio.

Can't really offer advice for C, other than don't do it unless you have to.

A client/server architecture would definitely be the simplest approach, but it requires some publically accessible server, which will most likely cost something, though not much.

Peer to peer is more complicated, but doesn't necessarily require a public server. The big issue with P2P applications is getting around NAT. Here's a decent paper detailing some of the common techniques for doing that: http://www.brynosaurus.com/pub/net/p2pnat/
thank you , much appreciated.
In my experience the issues with writing networking programs in C\C++ are the same issues that you always face in this language. If you write something that is going to fall on it's face then the language is perfectly content to oblige. If you didn't write anything to secure your connection against an attack, then nothing is going to be there to do it for you.

Otherwise networking in C\C++ is as simple as send() and recv() on every platform. You say you want asynchronous communication? Then dedicate one thread to sending and the other to receiving. It doesn't matter if you want to send text, video or an executable file it is always those same two functions.

The trick is in managing your buffers. You can't just take every bit of input and send it right to it's destination, that is what telnet did wrong. The sender should always notify the recipient of the size of the message it intends to send before it is actually sent. This way the recipient can allocate the buffer it requires dynamically and tell the sender when it is ready, or it can tell the sender to take a hike. This is sort of how I send files through the network for software deployments at my office and it is dramatically faster then SMB.
Topic archived. No new replies allowed.