netutil

package
v3.0.0-rc.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package netutil contains network-related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FullyQualifiedHostname

func FullyQualifiedHostname() (string, error)

FullyQualifiedHostname returns the FQDN of the machine.

func FullyQualifiedHostnameOrPanic

func FullyQualifiedHostnameOrPanic() string

FullyQualifiedHostnameOrPanic is the same as FullyQualifiedHostname but panics in case of an error.

func JoinHostPort

func JoinHostPort(host string, port int32) string

JoinHostPort is an extension to net.JoinHostPort that also formats the integer port.

func ResolveIPv4Addrs

func ResolveIPv4Addrs(addr string) ([]string, error)

ResolveIPv4Addrs resolves the address:port part into IP address:port pairs

func SortRfc2782

func SortRfc2782(srvs []*net.SRV)

SortRfc2782 reorders SRV records as specified in RFC 2782.

func SplitHostPort

func SplitHostPort(addr string) (string, int, error)

SplitHostPort is an alternative to net.SplitHostPort that also parses the integer port. In addition, it is more tolerant of improperly escaped IPv6 addresses, such as "::1:456", which should actually be "[::1]:456".

Types

type ConnWithTimeouts

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

A ConnWithTimeouts is a wrapper to net.Comm that allows to set a read and write timeouts.

func NewConnWithTimeouts

func NewConnWithTimeouts(conn net.Conn, readTimeout time.Duration, writeTimeout time.Duration) ConnWithTimeouts

NewConnWithTimeouts wraps a net.Conn with read and write deadilnes.

func (ConnWithTimeouts) Read

func (c ConnWithTimeouts) Read(b []byte) (int, error)

Read sets a read deadilne and delegates to conn.Read.

func (ConnWithTimeouts) SetDeadline

func (c ConnWithTimeouts) SetDeadline(t time.Time) error

SetDeadline implements the Conn SetDeadline method.

func (ConnWithTimeouts) SetReadDeadline

func (c ConnWithTimeouts) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (ConnWithTimeouts) SetWriteDeadline

func (c ConnWithTimeouts) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (ConnWithTimeouts) Write

func (c ConnWithTimeouts) Write(b []byte) (int, error)

Write sets a write deadline and delagates to conn.Write

Jump to

Keyboard shortcuts

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