README

Package tcp provides TCP-level socket options that allow manipulation of TCP connection facilities.

GoDoc Build Status Build status Go Report Card

Documentation

Overview

    Package tcp implements TCP-level socket options.

    The package provides TCP-level socket options that allow manipulation of TCP connection facilities.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Conn

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

      A Conn represents an end point that uses TCP connection. It allows to set non-portable, platform-dependent TCP-level socket options.

      Example

        Monitoring a TCP connection

        For now only Darwin, FreeBSD, Linux and NetBSD kernels support the TCP information option. A custom net.Dial function that hooks up an underlying transport connection must be prepared before monitoring.

        Output:
        
        

        func NewConn

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

          NewConn returns a new end point.

          func (*Conn) Available

          func (c *Conn) Available() int

            Available returns how many bytes are unused in the underlying socket write buffer. It returns -1 when the platform doesn't support this feature.

            func (*Conn) Buffered

            func (c *Conn) Buffered() int

              Buffered returns the number of bytes that can be read from the underlying socket read buffer. It returns -1 when the platform doesn't support this feature.

              func (*Conn) Option

              func (c *Conn) Option(level, name int, b []byte) (tcpopt.Option, error)

                Option returns a socket option.

                func (*Conn) OriginalDst

                func (c *Conn) OriginalDst() (net.Addr, error)

                  OriginalDst returns an original destination address, which is an address not modified by intermediate entities such as network address and port translators inside the kernel, on the connection.

                  Only Linux and BSD variants using PF support this feature.

                  func (*Conn) SetOption

                  func (c *Conn) SetOption(o tcpopt.Option) error

                    SetOption sets a socket option.