transport

package
v0.0.0-...-be2ac48 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package transport provides a context wrapper and error handling around a UDP connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport interface {

	// Address returns the IP:port of the remote device. This will always have
	// the port, even if the address provided was missing it (we default to
	// 623).
	Address() net.Addr

	// Send encapsulates the provided data in a UDP packet and sends it to the
	// BMC's address. It then blocks until a packet is received, and returns the
	// data it contains. If the context expires before all of this is performed,
	// or there is a network error, the returned slice will be nil and the error
	// will be returned.
	Send(context.Context, []byte) ([]byte, error)

	// Close cleanly shuts down the underlying connection, returning any error
	// that occurs. It is envisaged that this call is deferred as soon as the
	// transport is successfully created.
	Close() error
}

Transport defines an interface capable of sending and receiving data to and from a device. It logically represents a UDP socket and receive buffer. Unless specified otherwise, access must be serialised.

func New

func New(addr string) (Transport, error)

New establishes a connection to a UDP endpoint. It is recommended to defer a call to Close() immediately after the error check.

Jump to

Keyboard shortcuts

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