net: golang.org/x/net/internal/socket Index | Files

package socket

import "golang.org/x/net/internal/socket"

Package socket provides a portable interface for socket system calls.

Index

Package Files

cmsghdr.go cmsghdr_linux_64bit.go error_unix.go iovec_64bit.go mmsghdr_unix.go msghdr_linux.go msghdr_linux_64bit.go rawconn.go rawconn_mmsg.go rawconn_msg.go socket.go sys.go sys_linux.go sys_linux_amd64.go sys_posix.go sys_unix.go zsys_linux_amd64.go

Variables

var (
    // NativeEndian is the machine native endian implementation of
    // ByteOrder.
    NativeEndian binary.ByteOrder
)

func ControlMessageSpace Uses

func ControlMessageSpace(dataLen int) int

ControlMessageSpace returns the whole length of control message.

type Conn Uses

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

A Conn represents a raw connection.

func NewConn Uses

func NewConn(c net.Conn) (*Conn, error)

NewConn returns a new raw connection.

func (*Conn) RecvMsg Uses

func (c *Conn) RecvMsg(m *Message, flags int) error

RecvMsg wraps recvmsg system call.

The provided flags is a set of platform-dependent flags, such as syscall.MSG_PEEK.

func (*Conn) RecvMsgs Uses

func (c *Conn) RecvMsgs(ms []Message, flags int) (int, error)

RecvMsgs wraps recvmmsg system call.

It returns the number of processed messages.

The provided flags is a set of platform-dependent flags, such as syscall.MSG_PEEK.

Only Linux supports this.

func (*Conn) SendMsg Uses

func (c *Conn) SendMsg(m *Message, flags int) error

SendMsg wraps sendmsg system call.

The provided flags is a set of platform-dependent flags, such as syscall.MSG_DONTROUTE.

func (*Conn) SendMsgs Uses

func (c *Conn) SendMsgs(ms []Message, flags int) (int, error)

SendMsgs wraps sendmmsg system call.

It returns the number of processed messages.

The provided flags is a set of platform-dependent flags, such as syscall.MSG_DONTROUTE.

Only Linux supports this.

type ControlMessage Uses

type ControlMessage []byte

A ControlMessage represents the head message in a stream of control messages.

A control message comprises of a header, data and a few padding fields to conform to the interface to the kernel.

See RFC 3542 for further information.

func NewControlMessage Uses

func NewControlMessage(dataLen []int) ControlMessage

NewControlMessage returns a new stream of control messages.

func (ControlMessage) Data Uses

func (m ControlMessage) Data(dataLen int) []byte

Data returns the data field of the control message at the head on w.

func (ControlMessage) Marshal Uses

func (m ControlMessage) Marshal(lvl, typ int, data []byte) (ControlMessage, error)

Marshal marshals the control message at the head on w, and returns the next control message.

func (ControlMessage) MarshalHeader Uses

func (m ControlMessage) MarshalHeader(lvl, typ, dataLen int) error

MarshalHeader marshals the header fields of the control message at the head on w.

func (ControlMessage) Next Uses

func (m ControlMessage) Next(dataLen int) ControlMessage

Next returns the control message at the next on w.

Next works only for standard control messages.

func (ControlMessage) Parse Uses

func (m ControlMessage) Parse() ([]ControlMessage, error)

Parse parses w as a single or multiple control messages.

Parse works for both standard and compatible messages.

func (ControlMessage) ParseHeader Uses

func (m ControlMessage) ParseHeader() (lvl, typ, dataLen int, err error)

ParseHeader parses and returns the header fields of the control message at the head on w.

type Message Uses

type Message struct {
    // When writing, the Buffers field must contain at least one
    // byte to write.
    // When reading, the Buffers field will always contain a byte
    // to read.
    Buffers [][]byte

    // OOB contains protocol-specific control or miscellaneous
    // ancillary data known as out-of-band data.
    OOB []byte

    // Addr specifies a destination address when writing.
    // It can be nil when the underlying protocol of the raw
    // connection uses connection-oriented communication.
    // After a successful read, it may contain the source address
    // on the received packet.
    Addr net.Addr

    N     int // # of bytes read or written from/to Buffers
    NN    int // # of bytes read or written from/to OOB
    Flags int // protocol-specific information on the received message
}

A Message represents an IO message.

type Option Uses

type Option struct {
    Level int // level
    Name  int // name; must be equal or greater than 1
    Len   int // length of value in bytes; must be equal or greater than 1
}

An Option represents a sticky socket option.

func (*Option) Get Uses

func (o *Option) Get(c *Conn, b []byte) (int, error)

Get reads a value for the option from the kernel. It returns the number of bytes written into b.

func (*Option) GetInt Uses

func (o *Option) GetInt(c *Conn) (int, error)

GetInt returns an integer value for the option.

The Len field of Option must be either 1 or 4.

func (*Option) Set Uses

func (o *Option) Set(c *Conn, b []byte) error

Set writes the option and value to the kernel.

func (*Option) SetInt Uses

func (o *Option) SetInt(c *Conn, v int) error

SetInt writes the option and value to the kernel.

The Len field of Option must be either 1 or 4.

Package socket imports 10 packages (graph) and is imported by 3 packages. Updated 2017-10-21. Refresh now. Tools for package owners.