Click here to Skip to main content
Licence CPOL
First Posted 6 May 2006
Views 138,717
Downloads 13,026
Bookmarked 61 times

Chat Client Server

By | 18 May 2007 | Article
An implementation of chat client and server with win32 sockets
Sample Image - chat_client_server.jpg - Click to enlarge image

Introduction

Recently I got myself introduced to socket programming. I read through many books and articles to get an insight into the subject. After learning a bit, I decided to share my knowledge with the world. For this purpose, I created a simple console based chat application. I hope this will be a good reference code for C++ socket programming. I am going to introduce the following concepts to you here.

  • Sockets
  • Multi threading

What is Chat Client Server?

The demo project given along with this article consists of two console-based applications.

Chat Server

Chat server is an application which does the following operations:

  • Listens for incoming calls from clients. Client running in any PC can connect to the server if IP address of the server is known.
  • Listens for messages from all the connected clients.
  • Broadcasts the message from clients to all the clients connected to the server.
  • You can also type-in messages in the server, which will be broadcasted to all the clients.

Chat Client

Chat client does the following things:

  • Sends messages to server as well as to all the connected clients.
  • Views the messages from all the clients and server.

Please download the PDF document to read the rest of the documentation. I have created a PDF because the article consists of 2-3 diagrams.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Boby Thomas P



Australia Australia

Member

Check my homepage for more details - Click Here

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionClient Server between windows and linux Pinmemberabhishek3170422:02 20 Feb '12  
GeneralMy vote of 1 PinmemberZeshan Khan20:45 15 Jan '12  
GeneralMy vote of 4 Pinmembersonu janjua2:27 28 Oct '11  
GeneralMy vote of 5 Pinmemberpeejaysales3:57 11 Oct '11  
QuestionAfxwin.h not found PinmemberMember 80886570:51 16 Jul '11  
AnswerRe: Afxwin.h not found Pinmemberpeejaysales3:58 11 Oct '11  
Questionthanks for sharing PinmemberClaireClaire20:39 12 Jul '11  
GeneralQuestion Pinmemberfranchela5:12 19 Mar '11  
GeneralUnhandled exception Pinmemberad_robot3:07 7 Jan '11  
GeneralMy vote of 4 PinmemberGokulnath00720:52 26 Dec '10  
Generalc code for chat server........plzzzzzzzzzz...urgent.......... Pinmemberankit1011873:37 3 Apr '10  
Generalplzzzzzzzzzzzz Pinmemberharsh_amity21:10 1 Apr '10  
QuestionConnectin to my server on remote machine Pinmembermehul95955:25 26 Mar '10  
GeneralMy vote of 1 Pinmembersathiyapraka22:44 7 Jan '10  
Generalthnx Pinmemberharshmttl7:21 22 Jan '09  
GeneralRespected sir Pinmembershakher sumsher18:54 21 Jan '09  
GeneralC cde for chat server Pinmemberavinashk140:08 29 Aug '08  
GeneralI want to implement a chat server/client Pinmemberricha.cseit3:58 28 Feb '08  
GeneralRe: I want to implement a chat server/client Pinmemberchandreshpratapsrivastava4:18 23 Mar '09  
QuestionWant to develop a chat client PinmemberdipuThegr818:16 14 Nov '07  
Generalwchar_t PinmemberMan_cool19:42 9 Jul '07  
QuestionError? PinmemberXHungChung0:33 10 Nov '06  
AnswerRe: Error? PinmemberBoby Thomas P0:37 10 Nov '06  
Generalbehavior after cable break Win2k/ Winxp PinmemberBennet Yee20:13 12 May '06  
Generali have an idea Pinmembernoise@BUPT15:52 9 May '06  
glad to view this article.i have a little idea.when a client sends message to the server, can u define a message format?for example,char[4096],the first 256bytes used for the nickname,when server send these back to all clients,them print the nickname before(-->),so the server donnot need to maintain a database for the nickname,and the clinet can change the nickname anytime he/she wants.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 19 May 2007
Article Copyright 2006 by Boby Thomas P
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid