rup

package module
v0.0.0-...-7b7dd47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2019 License: MIT Imports: 12 Imported by: 0

README

logo

rup A reliable udp server & client library

the name is based on the rudp from plan 9 but witout the d

But why?

Fist of all i just made this to learn a lot.
But secondly i'm planing to use this in a bigger project that needs a libary/protocol like this to succeed.

Feather goals

NOTE: The checked boxes are completed

  • Fast
  • Reliable
  • Support for UDP hole punching
Why no security

I want to use this project for something else where i'm going to inplment my own way of encrypting.
because i don't want to dubble encrypt my pacakges i'll leave the ecryption out for now but i'll add encryption to the library if needed.

Where are the docs

At the moment the project is still in a early stage of development and there for lots of changers.
Because of that i'm not providing any documentation for now.

Spec

See spec.md

Alternatives

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReqTimedOut tells if the request is timed out
	ErrReqTimedOut = errors.New("Request timed out")
)

Functions

This section is empty.

Types

type Context

type Context struct {
	// The request id
	ID string

	// From tells from who the message was
	// net.Addr.String()
	From string

	// MessageSize is the size of the message in amound of bytes
	// This can be used for tracking the recive process
	MessageSize uint64

	// ReciveSize is the size of what we currently have recived (this does not count the upcommingParts)
	// If this is equal or more than MessageSize the message is completed
	//
	// This library doesn't check for data integrity thus the
	// ReciveSize can't be trusted to go never above the MessageSize
	ReciveSize uint64

	// Stream is the channel whereover the library will send all message data
	// If there is no data is left (thus the message is completed) this channel will be closed,
	// This can be checked using:
	//   data, ok := <- c.Stream
	//   if !ok {
	//	   fmt.Println("No data left!, Message completed")
	//   }
	Stream chan []byte
	// contains filtered or unexported fields
}

Context contains all information

type Server

type Server struct {
	ServAddr string
	Reciver  func(*Context)

	BufferSize uint64
	// contains filtered or unexported fields
}

Server is the global type for dealing with the server

func Start

func Start(options StartOptions) (*Server, error)

Start creates a server instace When provided no address address it will take a ramdom poort on 0.0.0.0 If there are more than 1 addresess defined the program will return an error

func (*Server) Send

func (s *Server) Send(to string, msg []byte) error

Send sends a message

type StartOptions

type StartOptions struct {
	// Address is a *ustom address use
	// If empty the program will select one for you
	Address string

	// BufferSize is the buffer size used for the udp pacakge
	// The later they are the less cpu intensive they are butt they will be less reliable
	// Default (8192) is used when BufferSize <= 0
	BufferSize uint64
}

StartOptions are the options for the start function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL