tnet

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDisconnectedError

func IsDisconnectedError(err error) bool

IsDisconnectedError returns true if the given error is related to a disconnected socket.

func ParseAddress

func ParseAddress(addressString string, defaultProtocol string) (protocol, address string)

ParseAddress takes an address and tries to extract the protocol from it. Protocols may be prepended by the "protocol://" notation. If no protocol is given, defaultProtocol is returned. The first parameter returned is the address, the second denotes the protocol. The protocol is allways returned as lowercase string. If only a number is given as an address the number is assumed to be a port. As of this "80" and ":80" will return ":80" as the address.

func SplitAddress

func SplitAddress(addressString string, defaultProtocol string) (protocol, host, port string, err error)

SplitAddress splits an address of the form "protocol://host:port" into its components. If no protocol is given, defaultProtocol is used. This function uses net.SplitHostPort and ParseAddress.

Types

type StopListener

type StopListener struct {
	*net.TCPListener
	// contains filtered or unexported fields
}

StopListener is a wrapper around net.TCPListener that allows to gracefully shut down a connection loop.

func NewStopListener

func NewStopListener(address string) (*StopListener, error)

NewStopListener creates a new, stoppable TCP server connection. Address needs to be cmpliant to net.Listen.

func (*StopListener) Accept

func (listen *StopListener) Accept() (net.Conn, error)

Accept is analogous to net.TCPListener.Accept but may return a connection closed error if the connection was requested to shut down.

func (*StopListener) Close

func (listen *StopListener) Close() error

Close requests a connection close on this listener

type StopRequestError

type StopRequestError struct{}

StopRequestError is not an error but a note that the connection was requested to be closed.

func (StopRequestError) Error

func (err StopRequestError) Error() string

Error implements the standard error interface

type URI

type URI struct {
	Protocol string
	Address  string
	Port     uint16
}

URI stores parts parsed from an URI string.

func SplitAddressToURI

func SplitAddressToURI(addressString string, defaultProtocol string) (uri URI, err error)

SplitAddressToURI acts like SplitAddress but returns an URI struct instead.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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