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
- func Fd(c io.Closer) int
- func ReadWithConn(src *net.UnixConn, dst []byte) (int, net.Conn, error)
- func ReadWithFile(src *net.UnixConn, dst []byte) (int, *os.File, error)
- func SocketPair() (*net.UnixConn, *net.UnixConn, error)
- func WriteWithConn(dst *net.UnixConn, msg []byte, conn net.Conn) (int, error)
- func WriteWithFile(dst *net.UnixConn, msg []byte, handle *os.File) (int, error)
Constants ¶
const Implemented = true
Variables ¶
This section is empty.
Functions ¶
func Fd ¶
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 ¶
ReadWithConn is like ReadWithFile, except that it converts the in-band file descriptor to a net.Conn rather than an os.File.
func ReadWithFile ¶
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 ¶
SocketPair returns a pair of connected unix sockets.
func WriteWithConn ¶
WriteWithConn is similar to WriteWithFile, except that it sends the file descriptor associated with a net.Conn rather than an os.File.
Types ¶
This section is empty.