Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.
acdhemtosPublic archive

About

A simple peer-to-peer UDP chat application for Windows written in C++.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

UDP Chat

A simple peer-to-peer UDP chat application for Windows written in C++.

Features

  • Real-time messaging over UDP
  • Peer-to-peer communication
  • Preserves partially typed input when messages arrive
  • Graceful shutdown using Ctrl+C
  • No central server required
  • No third-party dependencies

Requirements

Operating System

  • Windows 10 or newer

Compiler

Any C++17-compatible Windows compiler.

Tested with:

  • MinGW-w64

Should also work with:

  • Microsoft Visual Studio (MSVC)
  • MSYS2 UCRT64
  • MSYS2 MINGW64

Libraries

Only standard Windows libraries are required:

  • Winsock2 (ws2_32)
  • Windows Console API

No external dependencies are needed.

Setup

git clone https://github.com/acdhemtos/udp-chat.git
cd udp-chat
cd code
g++ main.cpp network.cpp console.cpp -o ../chat.exe -std=c++17 -lws2_32
cd ../

The Compiler specific command may be different.

Running

The application accepts three command-line arguments:

chat.exe <local_port> <peer_ip> <peer_port>

Parameters

Parameter Description
local_port Port this instance listens on
peer_ip IP address of the remote peer
peer_port Port the remote peer listens on

Local Testing

Open two terminal windows.

Terminal 1

chat.exe 5000 127.0.0.1 5001

Terminal 2

chat.exe 5001 127.0.0.1 5000

Messages typed in either terminal will appear in the other.

Demo

Terminal Demo

Exiting

You can exit the application by pressing Ctrl+C.

UDP Notes

Because UDP is connectionless:

  • Delivery is not guaranteed.
  • Packets may arrive out of order.
  • Packets may be lost.
  • There is no retransmission mechanism.

Firewall

The first time the application runs, Windows Firewall may display a prompt.

If you want to communicate across machines, allow access on the desired network type.

Communicating Across Machines

Assume:

Machine IP Address
A 192.168.1.10
B 192.168.1.25

Machine A

chat.exe 5000 192.168.1.25 5001

Machine B

chat.exe 5001 192.168.1.10 5000

Both machines must:

  • Be reachable on the network
  • Allow UDP traffic through the firewall
  • Use matching peer ports

Limitations

Current version does not include:

  • Message delivery guarantees
  • Encryption
  • Authentication
  • Usernames
  • File transfer
  • Group chat
  • Message history

About

A simple peer-to-peer UDP chat application for Windows written in C++.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages