Skip to content
📦 Send network packets over a TCP or UDP connection.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.drone.yml Use stricter linter settings May 24, 2019
.gitignore Initial commit Oct 29, 2017
IOError.go Minor change May 27, 2019
LICENSE Updated license Oct 30, 2017
Packet.go Improved packet.Write Dec 11, 2018 Updated README May 24, 2019 Use akyoto/readme May 6, 2019
Stream.go Improved channel type safety May 27, 2019
Stream_test.go Improved tests May 24, 2019
Utils.go Heavily improved coverage May 7, 2019
go.mod Clean up dependencies May 12, 2019
go.sum Clean up dependencies May 12, 2019


Godoc Report Tests Coverage Sponsor

Send network packets over a TCP or UDP connection.


Packet is the main class representing a single network message. It has a byte code indicating the type of the message and a []byte type payload.


A stream has a send and receive channel with a hot-swappable connection for reconnects. The user has the responsibility to register a callback to consume errors via OnError.


// Connect to a server
conn, _ := net.Dial("tcp", "localhost:7000")

// Create a stream
stream := packet.NewStream(1024)

// Send a message
stream.Outgoing <- packet.New(0, []byte("ping"))

// Receive message
msg := <-stream.Incoming

// Check message contents
if string(msg.Data) != "pong" 

Hot-swap example

// Close server connection to simulate server death

// Send packet while server is down (will be buffered until it reconnects)
client.Outgoing <- packet.New(0, []byte("ping"))

// Reconnect
newServer, _ := net.Dial("tcp", "localhost:7000")

// Hot-swap connection

// The previously buffered messages in the Outgoing channel will be sent now.


Please take a look at the style guidelines if you'd like to make a pull request.


Cedric Fung Scott Rayapoullé Eduard Urbach
Cedric Fung Scott Rayapoullé Eduard Urbach

Want to see your own name here?

You can’t perform that action at this time.