Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / Win32

Chat Client Server

Rate me:
Please Sign up or sign in to vote.
4.21/5 (72 votes)
18 May 2007CPOL1 min read 333.8K   42.9K   79   44
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)


Written By
Software Developer (Senior) DWS
Australia Australia

Comments and Discussions

 
QuestionThank you for share Pin
Nguyễn khắc Tấn K23129-Oct-22 21:17
Nguyễn khắc Tấn K23129-Oct-22 21:17 
QuestionConnecting to server Pin
Member 135619456-Dec-17 8:22
Member 135619456-Dec-17 8:22 
QuestionRun the project Pin
Member 135595355-Dec-17 5:09
Member 135595355-Dec-17 5:09 
QuestionProblem here! Pin
Member 1216378624-Nov-15 4:29
Member 1216378624-Nov-15 4:29 
AnswerRe: Problem here! Pin
Member 1235688228-Feb-16 1:23
Member 1235688228-Feb-16 1:23 
Questionasdf Pin
Member 1127666730-Nov-14 22:58
Member 1127666730-Nov-14 22:58 
GeneralThanks for Sharing Pin
ripon12323-Jun-13 8:57
ripon12323-Jun-13 8:57 
QuestionHow would you make it so, you wouldn't receive your own messages? Pin
Member 939065929-Aug-12 0:47
Member 939065929-Aug-12 0:47 
Questionmfc Pin
ZarokovM30-Jul-12 9:56
ZarokovM30-Jul-12 9:56 
QuestionClient Server between windows and linux Pin
abhishek3170420-Feb-12 22:02
abhishek3170420-Feb-12 22:02 
GeneralMy vote of 1 Pin
Zeshan Khan15-Jan-12 20:45
Zeshan Khan15-Jan-12 20:45 
GeneralRe: My vote of 1 Pin
Member 1116586718-Nov-17 8:48
Member 1116586718-Nov-17 8:48 
GeneralMy vote of 4 Pin
sonu janjua28-Oct-11 2:27
sonu janjua28-Oct-11 2:27 
GeneralMy vote of 5 Pin
peejays11-Oct-11 3:57
peejays11-Oct-11 3:57 
QuestionAfxwin.h not found Pin
Member 808865716-Jul-11 0:51
Member 808865716-Jul-11 0:51 
how do i fix this?
AnswerRe: Afxwin.h not found Pin
peejays11-Oct-11 3:58
peejays11-Oct-11 3:58 
GeneralRe: Afxwin.h not found Pin
zuiopvbnm10-Dec-12 5:00
zuiopvbnm10-Dec-12 5:00 
Questionthanks for sharing Pin
ClaireClaire12-Jul-11 20:39
ClaireClaire12-Jul-11 20:39 
GeneralQuestion Pin
franchela19-Mar-11 5:12
franchela19-Mar-11 5:12 
GeneralUnhandled exception Pin
ad_robot7-Jan-11 3:07
ad_robot7-Jan-11 3:07 
GeneralMy vote of 4 Pin
Gokulnath00726-Dec-10 20:52
Gokulnath00726-Dec-10 20:52 
Generalc code for chat server........plzzzzzzzzzz...urgent.......... Pin
ankit1011873-Apr-10 3:37
ankit1011873-Apr-10 3:37 
Generalplzzzzzzzzzzzz Pin
harsh_amity1-Apr-10 21:10
harsh_amity1-Apr-10 21:10 
QuestionConnectin to my server on remote machine Pin
mehul959526-Mar-10 5:25
mehul959526-Mar-10 5:25 
GeneralMy vote of 1 Pin
sathiyapraka7-Jan-10 22:44
sathiyapraka7-Jan-10 22:44 

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

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