ipc

package module
v0.0.0-...-a21c3a6 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Inter-Process Communication

Uses a UDP server to communicate between processes. Limits communication to that originating on 127.0.0.1.

GoDoc

Documentation

Overview

Package ipc handles inter-process communication using UDP. It limits communication to 127.0.0.1 and does not handle packet order or dropped packets because these are unlikely issues locally.

Index

Constants

This section is empty.

Variables

View Source
var PacketSize = 50000

PacketSize is the max packet size, it's set a bit less than the absolute max at a nice, round value.

Functions

This section is empty.

Types

type Package

type Package struct {
	ID   uint32
	Body []byte
	Addr *rnet.Addr
	Len  int
	// contains filtered or unexported fields
}

Package is used to assemble the messages and send them through the channel when they are complete.

type Proc

type Proc struct {
	// contains filtered or unexported fields
}

Proc represents a process that can send and receive communication from other local Procs over UDP.

func New

func New(port rnet.Port) (*Proc, error)

New returns a Proc for sending and receiving communications with other local processes. The server will not be running initially.

func RunNew

func RunNew(port rnet.Port) (*Proc, error)

RunNew returns a Proc for sending and receiving communications with other local processes. The server will be running initially.

func (*Proc) Close

func (p *Proc) Close() error

Close will close the connection, freeing the port

func (*Proc) GetPort

func (p *Proc) GetPort() rnet.Port

GetPort returns the UDP port

func (*Proc) Handler

func (p *Proc) Handler(handler func(*Package))

Handler adds a handler that will be used instead of the return channel

func (*Proc) IsOpen

func (p *Proc) IsOpen() bool

IsOpen returns true if the connection is open. If the server is closed, it can neither send nor receive

func (*Proc) IsRunning

func (p *Proc) IsRunning() bool

IsRunning indicates if the listen loop is running

func (*Proc) Run

func (p *Proc) Run()

Run will start the listen loop. Calling run multiple times will not start multiple listen loop.

func (*Proc) Send

func (p *Proc) Send(id uint32, msg []byte, port rnet.Port)

Send takes an id, a message and the port of the receiving process and sends the message to the other process. It prepends the length of the messsage. Unlike the packeter, this does not worry about dropped packets or ordering.

func (*Proc) Stop

func (p *Proc) Stop() error

Stop will stop the server

func (*Proc) String

func (p *Proc) String() string

String returns the address of the process

Jump to

Keyboard shortcuts

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