Package tcp provides various TCP-related utilities. The TCP mux code provided by this package originated with InfluxDB.



    View Source
    const (
    	// DefaultTimeout is the default length of time to wait for first byte.
    	DefaultTimeout = 30 * time.Second


    This section is empty.


    This section is empty.


    type Layer

    type Layer struct {
    	// contains filtered or unexported fields

      Layer represents the connection between nodes.

      func (*Layer) Accept

      func (l *Layer) Accept() (net.Conn, error)

        Accept waits for the next connection.

        func (*Layer) Addr

        func (l *Layer) Addr() net.Addr

          Addr returns the local address for the layer.

          func (*Layer) Close

          func (l *Layer) Close() error

            Close closes the layer.

            func (*Layer) Dial

            func (l *Layer) Dial(addr string, timeout time.Duration) (net.Conn, error)

              Dial creates a new network connection.

              type Mux

              type Mux struct {
              	// The amount of time to wait for the first header byte.
              	Timeout time.Duration
              	// Out-of-band error logger
              	Logger *log.Logger
              	// Whether to skip verification of other nodes' certificates.
              	InsecureSkipVerify bool
              	// contains filtered or unexported fields

                Mux multiplexes a network connection.

                func NewMux

                func NewMux(ln net.Listener, adv net.Addr) (*Mux, error)

                  NewMux returns a new instance of Mux for ln. If adv is nil, then the addr of ln is used.

                  func NewTLSMux

                  func NewTLSMux(ln net.Listener, adv net.Addr, cert, key, caCert string) (*Mux, error)

                    NewTLSMux returns a new instance of Mux for ln, and encrypts all traffic using TLS. If adv is nil, then the addr of ln is used.

                    func (*Mux) Listen

                    func (mux *Mux) Listen(header byte) *Layer

                      Listen returns a listener identified by header. Any connection accepted by mux is multiplexed based on the initial header byte.

                      func (*Mux) Serve

                      func (mux *Mux) Serve() error

                        Serve handles connections from ln and multiplexes then across registered listener.

                        func (*Mux) Stats

                        func (mux *Mux) Stats() (interface{}, error)

                          Stats returns status of the mux.

                          Source Files