unix

package
v0.0.0-...-0c426a5 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2014 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	R int = 1 << (32 - 1 - iota)
	W
)

Variables

This section is empty.

Functions

func Copy

func Copy(dst Sender, src Receiver) (int, error)

func FdConn

func FdConn(fd int) (n *net.UnixConn, err error)

FdConn wraps a file descriptor in a standard *net.UnixConn object, or returns an error if the file descriptor does not point to a unix socket. This creates a duplicate file descriptor. It's the caller's responsibility to close both.

func MsgDesc

func MsgDesc(payload []byte, attachment *os.File) string

MsgDesc returns a human readable description of a beam message, usually for debugging purposes.

func Pair

func Pair() (*Conn, *Conn, error)

func SendRPipe

func SendRPipe(dst Sender, data []byte) (*os.File, error)

SendRPipe create a pipe and sends its *read* end attached in a beam message to `dst`, with `data` as the message payload. It returns the *write* end of the pipe, or an error.

func SendWPipe

func SendWPipe(dst Sender, data []byte) (*os.File, error)

SendWPipe create a pipe and sends its *read* end attached in a beam message to `dst`, with `data` as the message payload. It returns the *write* end of the pipe, or an error.

func SocketPair

func SocketPair() (a *os.File, b *os.File, err error)

SocketPair is a convenience wrapper around the socketpair(2) syscall. It returns a unix socket of type SOCK_STREAM in the form of 2 file descriptors not bound to the underlying filesystem. Messages sent on one end are received on the other, and vice-versa. It is the caller's responsibility to close both ends.

func USocketPair

func USocketPair() (*UnixConn, *UnixConn, error)

Types

type Conn

type Conn struct {
	*UnixConn
}

func (*Conn) Close

func (c *Conn) Close() error

This implements beam.Sender.Close which *only closes the sender*. This is similar to the pattern of only closing go channels from the sender's side. If you want to close the entire connection, call Conn.UnixConn.Close.

func (*Conn) Receive

func (c *Conn) Receive(mode int) (*beam.Message, error)

func (*Conn) Send

func (c *Conn) Send(msg *beam.Message) (beam.Receiver, error)

type ReceiveCloser

type ReceiveCloser interface {
	Receiver
	Close() error
}

type ReceiveSender

type ReceiveSender interface {
	Receiver
	Sender
}

func Devnull

func Devnull() ReceiveSender

type Receiver

type Receiver interface {
	Receive() ([]byte, *os.File, error)
}

type SendCloser

type SendCloser interface {
	Sender
	Close() error
}

type Sender

type Sender interface {
	Send([]byte, *os.File) error
}

type UnixConn

type UnixConn struct {
	*net.UnixConn
	// contains filtered or unexported fields
}

func FileConn

func FileConn(f *os.File) (*UnixConn, error)

func ReceiveConn

func ReceiveConn(src Receiver) ([]byte, *UnixConn, error)

func SendConn

func SendConn(dst Sender, data []byte) (conn *UnixConn, err error)

func (*UnixConn) Receive

func (conn *UnixConn) Receive() (rdata []byte, rf *os.File, rerr error)

Receive waits for a new message on conn, and receives its payload and attachment, or an error if any.

If more than 1 file descriptor is sent in the message, they are all closed except for the first, which is the attachment. It is legal for a message to have no attachment or an empty payload.

func (*UnixConn) Send

func (conn *UnixConn) Send(data []byte, f *os.File) error

Send sends a new message on conn with data and f as payload and attachment, respectively. On success, f is closed

Jump to

Keyboard shortcuts

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