tcputil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 5 Imported by: 8

Documentation

Overview

package tcputil contains functions commonly used to manipulate TCP connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableTCPKeepAlive

func EnableTCPKeepAlive(conn net.Conn) error

EnableTCPKeepAlive enabled the KeepAlive option on a TCP connection.

Some cloud providers (like Google Compute Engine) blackhole inactive TCP connections, we need to set TCP keep alive option to prevent that. See: https://developers.google.com/compute/docs/troubleshooting#communicatewithinternet

The same problem can happen when one end of a TCP connection dies and the TCP FIN or RST packet doesn't reach the other end, e.g. when the machine dies, falls off the network, or when there is packet loss. So, it is best to enable this option for all TCP connections.

func NewTCPConn

func NewTCPConn(c net.Conn) flow.Conn

func TCPResolveAddrs

func TCPResolveAddrs(ctx *context.T, address string) ([]string, error)

Types

type TCP

type TCP struct{}

func (TCP) Dial

func (TCP) Dial(ctx *context.T, network, address string, timeout time.Duration) (flow.Conn, error)

Dial dials a net.Conn to a the specific address and adds framing to the connection.

func (TCP) Listen

func (TCP) Listen(ctx *context.T, network, address string) (flow.Listener, error)

Listen returns a listener that sets KeepAlive on all accepted connections. Connections returned from the listener will be framed.

func (TCP) Resolve

func (TCP) Resolve(ctx *context.T, network, address string) (string, []string, error)

Resolve performs a DNS resolution on the provided network and address.

Jump to

Keyboard shortcuts

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