Once a peer has started a listener, you connect to them by providing their address and port. The connection is established over TCP and an encryption handshake runs automatically before any messages are exchanged.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.
Connecting to a listener
Get the host's address
Ask your peer for the address they are listening on. It follows the format
host:port, for example 192.168.1.42:5555 for a machine on the same network, or a public IP for an internet connection.You must know the address before running the connect command. p2p-chat has no discovery mechanism — there is no way to browse for available hosts.
Run the connect command
go run . connect localhost:5555 for you.Connecting across machines
When your peer is on a different machine, replacelocalhost with their IP address.
Same local network (LAN)
Same local network (LAN)
Your peer runs:They share their local IP (e.g.
192.168.1.42). You run:Over the internet
Over the internet
Your peer shares their public IP address and has configured port forwarding on their router for the chosen port. You run:Replace
<public-ip> with the address they gave you.Disconnect behavior
When the session ends, one of the following happens depending on how it terminates.| Cause | Your terminal | Peer’s terminal |
|---|---|---|
Peer runs /quit | !<nick> left the chat then Disconnected | Disconnecting... then process exits |
You run /quit | Disconnecting... then process exits | !<nick> left the chat then Disconnected |
| Peer closes terminal abruptly | Disconnected (no leave message) | — |
Expected terminal output
| Event | Output |
|---|---|
| Connection succeeds | Connected to <address> |
| Encryption handshake completes | Encryption established. |
| Peer quits gracefully | Disconnected |
| Address unreachable | Go runtime error (connection refused / timeout) |