Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Project516/p2p-chat/llms.txt

Use this file to discover all available pages before exploring further.

p2p-chat is a minimal command-line chat program written in Go. One peer starts a listener that waits for an incoming TCP connection, and a second peer connects to it directly — no server, no account, no broker. This guide walks you through installing the prerequisites, starting both sides of the connection, and sending your first message.
You need two terminal windows open at the same time: one to run the listener and one to run the connecting peer. Both can be on the same machine, or on two different machines on the same network.
1

Install Go 1.26.2

p2p-chat requires Go 1.26.2 or later. Check whether you already have it:
go version
If the output shows go1.26.2 or higher, skip to the next step. Otherwise, install Go for your platform:
wget https://go.dev/dl/go1.26.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.26.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
To make the PATH change permanent, add the export line to your ~/.bashrc or ~/.profile and restart your shell.
2

Clone the repository

Clone p2p-chat and enter the project directory:
git clone https://github.com/Project516/p2p-chat.git
cd p2p-chat
3

Start the listener (terminal 1)

In your first terminal, start a listener on localhost:5555. This peer waits for an incoming connection.
go run . listen localhost:5555
Expected output:
Listening on localhost:5555
The process blocks here until the second peer connects.
You can change the address and port to anything you like — for example 0.0.0.0:9000 to accept connections from other machines on your network.
4

Connect from a second terminal (terminal 2)

Open a second terminal, navigate to the same project directory, and connect to the listener:
go run . connect localhost:5555
Expected output:
Connected to localhost:5555
At the same moment, the first terminal prints:
Connected
Both peers are now live. Anything you type in one terminal appears in the other.
5

Send a message and set a display name

Type a message in either terminal and press Enter to send it.To set your display name as it appears to the other peer, use the /nick command:
/nick alice
The other peer will see your messages attributed to alice from that point on.
6

Exit the session

To close your side of the connection, type:
/quit
This disconnects cleanly. The other peer’s terminal will return to a prompt.

Available commands

Once connected, the following slash commands are available in either terminal:
CommandDescription
/nickSet your display name as seen by the other peer
/quitDisconnect and exit the program
/versionPrint the current p2p-chat version
/helpList all available commands

Build docs developers (and LLMs) love