hi, I want to make a chat program using c++. Can you give me any site where i could find the concepts in building chat program? I will make a chat program similar to YahooMessenger.

Dani AI

Generated

As suggested, studying existing clients is useful. To make progress quickly, treat this as a small product: pick a minimal feature set, build a clean protocol and server-side state, then iterate. For an initial MVP include: account login, presence/online status, one-to-one messaging, and server storage for offline delivery. Delay group chat, file transfer and voice until the core is reliable.

Keep the protocol simple and robust. Use a clear framing strategy (length-prefixed messages are reliable), give each message a type and ID, and carry a small JSON or binary payload. This avoids common problems with partial reads/writes and mixed TCP packets. Example of a simple receive pattern (pseudocode):

uint32_t len_net;
recv_all(sock, &len_net, 4);
uint32_t len = ntohl(len_net);
std::vector<char> buf(len);
recv_all(sock, buf.data(), len);
// parse JSON or binary payload in buf

Choose an I/O model that fits your scale. For a desktop toy, a thread-per-connection or a small thread pool works; for production, use an asynchronous event loop (Boost.Asio is a mature C++ choice) and move CPU work off the I/O threads. Protect credentials and data: always use TLS for transport (OpenSSL or platform TLS), never store raw passwords (use Argon2/bcrypt with proper salts), and plan for reconnection/backoff and session expiry.

Practical pitfalls to watch for: handle partial sends/receives, set socket options (timeouts, TCP_NODELAY when appropriate), log binary traffic for debugging, and simulate NAT issues. If you later want direct client-to-client features (file or voice), expect to use STUN/TURN/ICE or relay through your server. Test with tools like Wireshark and write unit tests for framing/parsing early — that will save hours of debugging.

Recommended Answers

All 2 Replies

I'd recommend checking out the open-source [search]Gaim[/search] client's code, you will learn a lot by reading other people's source code.

As for chat concept... the concept is fairly simple, it's the implementation that's difficult. You'll definitely want to spend some time learning sockets and other network-programming goodies that you'll need to be able to write such a client from scratch. One of the most popular socket tutorials out there is Beej's:
http://beej.us/guide/bgnet/

Have fun.

thanx a lot...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.