https://github.com/rogercoll/basic-p2p
Basic p2p connection over TCP where peers exchange a version(of whatever) message to check their compatibility
https://github.com/rogercoll/basic-p2p
Last synced: about 1 month ago
JSON representation
Basic p2p connection over TCP where peers exchange a version(of whatever) message to check their compatibility
- Host: GitHub
- URL: https://github.com/rogercoll/basic-p2p
- Owner: rogercoll
- Created: 2020-04-15T18:45:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-21T17:17:44.000Z (about 5 years ago)
- Last Synced: 2025-03-20T14:52:47.793Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic p2p
Basic golang code to establish a TCP connection and exchange information
Example of the struct that is shared:
```go
type Version struct {
version uint32
timestamp uint64
addr_recv [4]uint8
addr_recv_port uint16
addr_trans [4]uint8
addr_trans_port uint16
}
```All is encoden in Little Endian order.
## Run
```sh
//Launch the server
go run main.go//Create a client
go test pkg/client/client_test.go
```