uds

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*net.UnixConn
}

Conn extends net.UnixConn with additional useful methods.

func FromFile

func FromFile(fd *os.File) (*Conn, error)

FromFile attempts to create a Conn from a file. The returned conn is independent from the file and closing one does not close the other.

func NewSocketpair

func NewSocketpair(t SocketType) (left, right *Conn, err error)

NewSocketpair creates a unix socket pair, returning the halves as files.

func (*Conn) ReadWithFDs

func (c *Conn) ReadWithFDs(b []byte, fds []*os.File) (n, fdn int, err error)

ReadWithFDs reads data and associated fds. Note that the underlying socket must be a datagram socket if you need the bytes read to exactly match the bytes sent with the FDs.

func (*Conn) WriteWithFDs

func (c *Conn) WriteWithFDs(b []byte, fds []*os.File) (n, fdn int, err error)

WriteWithFDs performs a write that may also send associated FDs. Note that unless the underlying socket is a datagram socket it is not guaranteed that the exact bytes written will match the bytes received with the fds on the reader side.

type SocketType

type SocketType int

SocketType encodes the type of desired socket (datagram or stream).

const (
	// SocketTypeDatagram indicates that the socket type should be a unix datagram. Most usecases should
	// prefer stream sockets, but datagram can be beneficial when passing fds since it lets you ensure that
	// the bytes you receive alongside the fds exactly match those sent with the fds.
	SocketTypeDatagram SocketType = syscall.SOCK_DGRAM
	// SocketTypeStream indicates the the socket type should be a streaming socket. This is a reasonable default
	// for most usecases, though datagram may be preferable if fd passing is being used.
	SocketTypeStream SocketType = syscall.SOCK_STREAM
)

Jump to

Keyboard shortcuts

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