BOMBA is a small multiplayer game written in C using UDP sockets (Winsock 2) and multithreading. Players join a match by manually entering the IP addresses of the participants and pass a virtual bomb before it explodes.
The project is mainly educational and focuses on low-level networking, custom protocols, and concurrency.
-
Each player starts the program and enters:
- Their public IP address
- A nickname
- The IP addresses of all players (up to 4)
-
Players announce their presence using a custom UDP protocol.
-
Once all players confirm their presence, the game starts automatically.
-
A master player is elected:
- The player with the highest IP address (numeric comparison) becomes the master.
- The master generates a random bomb timer and sends the first bomb.
-
When a player receives the bomb:
- They must press a key to pass it to another random player.
- If the timer expires before passing the bomb, the bomb explodes and that player loses.
-
When the bomb explodes on a player:
- All other players win.
- The program terminates.
- Language: C (C11)
- Platform: Windows
- Networking: UDP sockets (Winsock 2)
- Concurrency: Windows threads
- Communication model: Peer-to-peer
- Max players:
4 - Default port:
6000
Each instance of the program:
- Opens a UDP socket to send packets
- Runs a dedicated receiving thread to handle incoming messages
Communication is based on single-byte message headers:
| Code | Meaning |
|---|---|
CISONO |
Player presence announcement |
CONFERMA |
Presence confirmation |
RICEVUTABOMBA |
Bomb received (with remaining time) |
IOHOLABOMBA |
Player currently owns the bomb |
BOMBA |
Bomb explosion |
Nicknames are embedded directly in the packet payload following the header byte.
The game does not use a server.
Instead:
- Each player compares all known IP addresses
- The player with the highest numeric IP value becomes the game master
- The master initializes the game by generating the bomb timer
This approach keeps the architecture fully decentralized.
This implementation has several known limitations by design:
-
❌ No duplicate IP detection If two players share the same IP address, they are treated as the same participant. This is unlikely in WAN scenarios but still possible.
-
❌ No fault tolerance If a player closes the program while holding the bomb, or if the bomb is sent to a disconnected player, the game gets stuck and cannot continue.
-
❌ Manual IP entry All IP addresses must be entered manually, which is error-prone and not scalable.
-
❌ UDP reliability No packet loss detection, retries, or ordering guarantees are implemented.
These limitations are accepted to keep the project simple and focused on learning.
.
├── bin/ # Executable output
├── build/ # Object files
├── include/ # Header files
│ ├── bomba.h
│ └── mySocket.h
├── src/ # Source files
│ ├── bomba.c
│ ├── main.c
│ └── mySocket.c
└── Makefile
makeProduces:
bin/bomba.exe
Requires MinGW:
sudo apt install gcc-mingw-w64-x86-64Then:
makeThis still produces a Windows executable:
bin/bomba.exe
make cleanRemoves:
build/bin/
This project was created to practice:
- UDP socket programming
- Custom network protocols
- Multithreading
- Peer-to-peer coordination
- Makefile-based builds
- Cross-compilation concepts
It is not intended for production use.