Coders Packet

Real Time Server Client Chat using Web Sockets in C++

By Siddharth Vinayak Bawane

This project is a real-time server-client chat that is implemented using web sockets in C++

This project consists of two files namely server.cppand client.cpp.

The flow of the program is as follows:

Creating a new socket.
Attaching socket to port
Binding the socket
Listening for any clients
Accepting client connection
Send and receive messages

Creating a new socket.
Connecting to the server.
Send and receive messages

The communication type used for this application is TCP(transfer control protocol) because it is connection-oriented and reliable. '0' indicates IP(internet protocol) is used.
socket(AF_INET, SOCK_STREAM, 0))

You can choose any PORT to run this web socket.

To run this program you need to create an executable file for the server as well as the client as given below:


g++ server.cpp -o server


g++ client.cpp -o client

Make sure to run the server code before the client.
Given Below is the working of this project.



Further, you can connect multiple clients by using the concept of Multithreading.

Download Complete Code


No comments yet