fdchannel

package
v0.0.0-...-957f62e Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

Package fdchannel implements passing file descriptors between processes over Unix domain sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnectedSockets

func NewConnectedSockets() ([2]int, error)

NewConnectedSockets returns a pair of file descriptors, owned by the caller, representing connected sockets that may be passed to separate calls to NewEndpoint to create connected Endpoints.

Types

type Endpoint

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

Endpoint sends file descriptors to, and receives them from, another connected Endpoint.

Endpoint is not copyable or movable by value.

func NewEndpoint

func NewEndpoint(sockfd int) *Endpoint

NewEndpoint is a convenience function that returns an initialized Endpoint allocated on the heap.

func (*Endpoint) Destroy

func (ep *Endpoint) Destroy()

Destroy releases resources owned by ep. No other Endpoint methods may be called after Destroy.

func (*Endpoint) Init

func (ep *Endpoint) Init(sockfd int)

Init must be called on zero-value Endpoints before first use. sockfd must be a blocking AF_UNIX SOCK_SEQPACKET socket.

func (*Endpoint) RecvFD

func (ep *Endpoint) RecvFD() (int, error)

RecvFD receives an open file description from the connected Endpoint and returns a file descriptor representing it, owned by the caller.

func (*Endpoint) RecvFDNonblock

func (ep *Endpoint) RecvFDNonblock() (int, error)

RecvFDNonblock receives an open file description from the connected Endpoint and returns a file descriptor representing it, owned by the caller. If there are no pending receivable open file descriptions, RecvFDNonblock returns (<unspecified>, EAGAIN or EWOULDBLOCK).

func (*Endpoint) SendFD

func (ep *Endpoint) SendFD(fd int) error

SendFD sends the open file description represented by the given file descriptor to the connected Endpoint.

func (*Endpoint) Shutdown

func (ep *Endpoint) Shutdown()

Shutdown causes concurrent and future calls to ep.SendFD(), ep.RecvFD(), and ep.RecvFDNonblock(), as well as the same calls in the connected Endpoint, to unblock and return errors. It does not wait for concurrent calls to return.

Shutdown is the only Endpoint method that may be called concurrently with other methods.

Jump to

Keyboard shortcuts

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