transmit

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package transmit provides utility functions to proxy data through network connections, with control over timeouts.

Index

Constants

View Source
const DTU int64 = 1500

DTU is the default trasmitting unit used when copying data from one connection to another.

View Source
const DefaultIdleTimeout time.Duration = time.Minute * 5

DefaultIdleTimeout is the default duration of 5 minutes used to determine when to close an idle connection.

Variables

This section is empty.

Functions

func Data

func Data(ctx context.Context, src net.Conn, dst net.Conn) error

Data copies data from src to dst and the other way around. Closes the connections when no data is transferred for a defined duration, i.e. the idleTimeout value stored in the context or the DefaultIdleTimeout, if the former is not present.

func DurationFromContext

func DurationFromContext(ctx context.Context) (time.Duration, bool)

DurationFromContext extracts the idleTimeout from the context.

func NewContext

func NewContext(ctx context.Context, idleTimeout time.Duration, tu int64) context.Context

NewContext returns a context that stores the idleTimeout inside its Value field.

func TUFromContext

func TUFromContext(ctx context.Context) (int64, bool)

TUFromContext extracts the transmitting unit from context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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