YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

P2P-Chat-App

Workshop 3 - 08.03.2026 Ali Gokcek - 2021400012 Tested my program by myself with another MacOS computer. Readme and inline comments were extended and the code got licensed for open-sourcing (will make it public after the deadline).

License

P2P chat application over local WiFi using Python. Peer discovery uses UDP broadcast; messages use TCP unicast.

Protocol

Type Transport Fields Purpose
ASK UDP broadcast SENDER_IP Announce presence to subnet
REPLY TCP unicast RECEIVER_NAME, RECEIVER_IP Respond to discovery
MESSAGE TCP unicast SENDER_IP, SENDER_NAME, PAYLOAD (max 2 KB) Send a chat message

Project Structure

β”œβ”€β”€ config.py        # Tunable constants (port, timeouts, intervals, CIDR range)
β”œβ”€β”€ network.py       # NetworkManager β€” UDP broadcast, TCP send/receive, listeners
β”œβ”€β”€ p2p_chat.py      # P2PChat β€” protocol handlers, peer management, CLI (entry point)
└── requirements.txt

Requirements

  • Python 3.7+
  • macOS (uses ipconfig getifaddr en0 for IP detection)
  • Peers must be on the same WiFi / local subnet
  • No external dependencies β€” stdlib only

Usage

python3 p2p_chat.py

Commands

Command Description
/peers List known peers
/send <name@ip> <msg> Send a message to a peer
/help Show help
/quit Exit

Example Session

  Your name: alice
  Identity : alice@192.168.1.10
  Port     : 12487

> /peers
  - bob@192.168.1.42

> /send bob@192.168.1.42 Hello!
  You β†’ bob: Hello!

  [-] Peer left: bob@192.168.1.42

> /quit

Configuration

Constants can be adjusted in config.py:

Constant Default Description
PORT 12487 Port used for both UDP broadcast and TCP unicast
MAX_PAYLOAD_BYTES 2048 Maximum message payload size in bytes
SEND_TIMEOUT_SEC 3 TCP connect/send timeout in seconds
CIDR_RANGE 24 Subnet mask used to compute the broadcast address
BROADCAST_INTERVAL 10 Seconds between automatic ASK broadcasts
PEER_TIMEOUT 30 Seconds of silence before a peer is evicted
REAPER_INTERVAL 5 How often the reaper checks for stale peers

License

BSD 2-Clause Β© 2026 Ali GΓΆkΓ§ek β€” see LICENSE for full text.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support