• Stars
    star
    78
  • Rank 397,957 (Top 9 %)
  • Language
    Go
  • License
    Other
  • Created over 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“¦ Send network packets over a TCP or UDP connection.

packet

Godoc Report Tests Coverage Sponsor

Send network packets over a TCP or UDP connection.

Packet

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.

Stream

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.

Example

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

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

// 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
server.Close()

// 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
client.SetConnection(newServer)

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

Style

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

Sponsors

Cedric Fung Scott RayapoullΓ© Eduard Urbach
Cedric Fung Scott RayapoullΓ© Eduard Urbach

Want to see your own name here?

More Repositories

1

aero

πŸš„ High-performance web server for Go.
Go
559
star
2

nano

πŸ€ Fast, decentralized and git-trackable database.
Go
48
star
3

codetree

🌲 Parses indented code and returns a tree structure.
Go
23
star
4

pixy

🌳 Template compiler similar to Jade/Pug.
Go
22
star
5

certificate

πŸ”’ Creates self-signed certificates for local development.
Go
22
star
6

pack

πŸ“¦ Packs the assets for your web server.
Go
19
star
7

scarlet

πŸ’‹ Style sheets preprocessor similar to Stylus.
Go
13
star
8

http

🎈 HTTP client with a clean API.
Go
13
star
9

graphql

πŸŒ€ GraphQL server with zero configuration.
Go
12
star
10

run

πŸƒ Runs an Aero project and restarts on code, template or style changes.
Go
11
star
11

log

πŸ“ Logging with multiple output targets.
Go
10
star
12

flow

➰ Provides flow control for async algorithms and simplified concurrency.
Go
8
star
13

markdown

🐬 Markdown wrapper.
Go
6
star
14

crawler

🚣 Web crawler.
Go
6
star
15

api

πŸ“ Automatically implements your REST API.
Go
6
star
16

cluster

β›² Network cluster.
Go
6
star
17

mirror

β†ͺ️ Reflect utilities for Go data types.
Go
5
star
18

nano-backup

βš“ Backup utility for nano databases.
Go
5
star
19

csp

πŸ”’ Helps building the "Content-Security-Policy" HTTP header.
Go
4
star
20

linter-performance

πŸš„ Logs response time and size for each page.
Go
3
star
21

manifest

πŸ”– Web manifest.
Go
3
star
22

session

πŸ“š Session manager.
Go
3
star
23

session-store-nano

πŸ“— Session store for the nano database.
Go
2
star
24

sitemap

🌐 Easily generate sitemaps.
Go
2
star
25

session-store-memory

πŸ“— Memory store for Aero sessions.
Go
1
star