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 ¶
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 ¶
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 ¶
Init must be called on zero-value Endpoints before first use. sockfd must be a blocking AF_UNIX SOCK_SEQPACKET socket.
func (*Endpoint) RecvFD ¶
RecvFD receives an open file description from the connected Endpoint and returns a file descriptor representing it, owned by the caller.
func (*Endpoint) RecvFDNonblock ¶
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 ¶
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.