Documentation ¶
Overview ¶
Package ipc provides a basic, dumb implementation of discrete messaging over various underlying transport protocols. Supported protocols are three kinds of Unix domain sockets (streaming, sequential packet, datagram) and local UDP sockets. For stream sockets, messages are prefixed with a 4 byte size so that the connection knows how many bytes to pull off for each message, preserving message boundaries.
The Conn interface represents a connection between two endpoints, and is returned by all functions that create clients; the Server interface represents a running server that spawns new Conns as clients connect to it. As a Server receives new connections, it will push new clients onto the channel accessible by Server.NewConns(). Allowing message routing between named clients is left to the higher-level multi package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSocketPath ¶
GetSocketPath returns a platform-appropriate path for the given socket name
Types ¶
type Conn ¶
type Conn interface { // Read a message - returns an empty slice if nothing is available, nil if // the connection has been shut down Read() []byte // Read a message and block until one becomes available (returns the buffer) // or the connection is closed (returns nil) ReadBlock() []byte // Write the given buffer to the other end Write([]byte) (int, error) // Close the connection and associated resources Close() error }
Conn represents a connection between two specific network endpoints - a client will hold one Conn to the server it's connected to, a server will hold individual Conns for each client that's connected to it.
func NewFileConn ¶
NewFileConn returns a connection that will operate on the given file descriptor
func NewUDPClient ¶
NewUDPClient returns a new Socket that will attempt to connect to the server on the given IP and port
func NewUnixClient ¶
NewUnixClient returns a new connection to the server at the specified path, assuming there are no errors when connecting
func NewUnixPacketClient ¶
NewUnixPacketClient returns a new server object listening for clients on the specified path, if no errors are encountered
type Server ¶
Server represents a running server waiting for connections. Client connections can be accessed by pulling new clients off the channel returned by NewConns().
func NewUDPServer ¶
NewUDPServer returns a new Server that will listen for clients on the given local port
func NewUnixPacketServer ¶
NewUnixPacketServer returns a new connection to the server at the specified path, assuming there are no errors when connecting
func NewUnixServer ¶
NewUnixServer returns a new server object listening for clients on the specified path, if no errors are encountered
func NewUnixgramServer ¶
NewUnixgramServer returns a new server object listening for clients on the specified path, if no errors are encountered