Skip to content

Manishym956/ChatRoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Chat Room (C++ Winsock)

A simple multi-client chat room application implemented in C++ using Winsock for Windows. The project consists of a server and a client, allowing multiple users to connect, broadcast messages, and send private messages.

Features

  • Multi-client support (each client handled in a separate thread)
  • Username registration
  • Public (broadcast) messaging
  • Private messaging using @username syntax
  • Graceful client disconnect handling

Files

  • server.cpp: The chat server. Handles multiple clients, message broadcasting, and private messaging.
  • client.cpp: The chat client. Connects to the server, sends/receives messages, and supports username input.

Requirements

  • Windows OS
  • C++ compiler (e.g., MSVC, MinGW)
  • Winsock2 library (included with most Windows C++ toolchains)

Build Instructions

Using Visual Studio (recommended)

  1. Create a new empty C++ project.
  2. Add server.cpp and/or client.cpp to the project.
  3. Build the project (Winsock2 is linked via #pragma comment(lib, "ws2_32.lib")).

Using g++ (MinGW)

g++ server.cpp -o server.exe -lws2_32
g++ client.cpp -o client.exe -lws2_32

Usage

1. Start the Server

Run the server on your machine:

./server.exe

The server listens on port 12345 by default.

2. Start Clients

Run one or more clients (on the same or different machines, if networked):

./client.exe
  • Enter your username when prompted.
  • Type messages and press Enter to send.
  • To send a private message: @username your message
  • To quit: type /quit

Example

[alice]: Hello everyone!
[bob]: Hi Alice!
@alice Hi Alice, this is a private message.

Notes

  • The server must be started before any clients connect.
  • The default server address is 127.0.0.1 (localhost). To connect over a network, modify the IP in client.cpp.
  • Only basic error handling is implemented.

License

This project is provided for educational purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages