network

package
v0.0.0-...-d4ca3cc Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENDBYTES = "\000\005\007\001\001\007\005\000" // Proof of end data sending
	WAITTIME = 5                                  // Seconds for Response from Server
	DMAXSIZE = 2 << 20                            // (2 ^ 20) * 2 = 2MiB
	BUFFSIZE = 4 << 10                            // (2 ^ 10) * 4 = 4KiB
)

Constant variables //

Variables

This section is empty.

Functions

func Handle

func Handle(option int, connect Conn, pack *Package, handle func(*Package) string) bool

Performs actions based on the received package option //

func SerializePackage

func SerializePackage(pack *Package) string

Converts a Package structure object to a string using its converting to JSON format. //

Types

type Conn

type Conn net.Conn

type Listener

type Listener net.Listener

func Listen

func Listen(address string, handle func(Conn, *Package)) Listener

A function that listens for a connection from the server (node) side //

type Package

type Package struct {
	Option int    // For example: GET_BALANCE, ADD_TRANSACTION
	Data   string // Data that get's by option's
}

Create structure of Data Packages //

func DeserializePackage

func DeserializePackage(data string) *Package

Inverse function of SerializePackage. Converts string into Package //

func Send

func Send(address string, pack *Package) *Package

Function that Sends data //

Jump to

Keyboard shortcuts

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