stdconn

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Unlicense Imports: 3 Imported by: 0

README

StdConn

This is a simple library that runs a client executable (in the example, it uses go run), creates a net.Conn with the stdin/stdout on both sides so the controller process can send IPC messages

How to use

stdconn.go and worker/worker.go are the reusable/convenience parts . stdconn.go is the net.Conn implementation and worker.go is mainly just a helper to start up an arbitrary executable with arbitrary arguments, it also has helpers to send stop and kill signals.

hello/implementation.go contains an example RPC implementation. Note that the most basic implementation should have a function like Bye() to stop the client, as closing its connection when using this IPC mechanism does not stop the child process which will block unless it is explicitly killed, and using os.Signal requires adding this handling code. So they are there for defcon IV type situations mainly and if using signals is preferred.

hello/wrapper contains a set of wrappers that shortens the RPC call syntax. If asynchronous calling is required, the wrappers would mimic the calling pattern with a cancel function and function that returns the reply or error over a channel. Probably this could be automated somehow but I haven't got the need or time for that right now.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StdConn

type StdConn struct {
	io.ReadCloser
	io.WriteCloser
	Quit chan struct{}
}

func New

func New(in io.ReadCloser, out io.WriteCloser, quit chan struct{}) (s StdConn)

func (StdConn) Close

func (s StdConn) Close() (err error)

func (StdConn) LocalAddr

func (s StdConn) LocalAddr() (addr net.Addr)

func (StdConn) Read

func (s StdConn) Read(b []byte) (n int, err error)

func (StdConn) RemoteAddr

func (s StdConn) RemoteAddr() (addr net.Addr)

func (StdConn) SetDeadline

func (s StdConn) SetDeadline(t time.Time) (err error)

func (StdConn) SetReadDeadline

func (s StdConn) SetReadDeadline(t time.Time) (err error)

func (StdConn) SetWriteDeadline

func (s StdConn) SetWriteDeadline(t time.Time) (err error)

func (StdConn) Write

func (s StdConn) Write(b []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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