usock

package
v0.0.0-...-86e9f11 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package usock implements a wrapper around the unix(7) SCM_RIGHTS API, which allows processes to exchange file handles over a unix(7) control socket.

Index

Constants

View Source
const Implemented = true

Variables

This section is empty.

Functions

func Fd

func Fd(c io.Closer) int

Fd returns the file descriptor associated with an io.Closer. The io.Closer should be either an *os.File or a net.Conn backed by a real socket file descriptor. If the argument to Fd is not backed by a file descriptor, Fd returns -1.

Note that the returned file descriptor isn't valid for any longer than the provided io.Closer remains open. Please only use Fd for informational purposes.

func ReadWithConn

func ReadWithConn(src *net.UnixConn, dst []byte) (int, net.Conn, error)

ReadWithConn is like ReadWithFile, except that it converts the in-band file descriptor to a net.Conn rather than an os.File.

func ReadWithFile

func ReadWithFile(src *net.UnixConn, dst []byte) (int, *os.File, error)

ReadWithFile reads data from src, and if it includes an out-of-band control message, it will try to turn it into a file handle.

func SocketPair

func SocketPair() (*net.UnixConn, *net.UnixConn, error)

SocketPair returns a pair of connected unix sockets.

func WriteWithConn

func WriteWithConn(dst *net.UnixConn, msg []byte, conn net.Conn) (int, error)

WriteWithConn is similar to WriteWithFile, except that it sends the file descriptor associated with a net.Conn rather than an os.File.

func WriteWithFile

func WriteWithFile(dst *net.UnixConn, msg []byte, handle *os.File) (int, error)

WriteWithFile writes a message to dst, including the provided file handle in an out-of-band control message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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