Documentation ¶
Overview ¶
package net is intended to provide compatible interfaces with the Go standard library's net package.
Index ¶
- Variables
- func SplitHostPort(hostport string) (host, port string, err error)
- func UseDriver(a Adapter)
- type Adapter
- type Addr
- type Conn
- type IP
- type SerialConn
- func (c *SerialConn) Close() error
- func (c *SerialConn) Read(b []byte) (n int, err error)
- func (c *SerialConn) SetDeadline(t time.Time) error
- func (c *SerialConn) SetReadDeadline(t time.Time) error
- func (c *SerialConn) SetWriteDeadline(t time.Time) error
- func (c *SerialConn) Write(b []byte) (n int, err error)
- type TCPAddr
- type TCPSerialConn
- type UDPAddr
- type UDPSerialConn
Constants ¶
This section is empty.
Variables ¶
var ( ErrWiFiMissingSSID = errors.New("missing SSID") ErrWiFiConnectTimeout = errors.New("WiFi connect timeout") )
Functions ¶
func SplitHostPort ¶
SplitHostPort splits a network address of the form "host:port", "host%zone:port", "[host]:port" or "[host%zone]:port" into host or host%zone and port.
A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80".
See func Dial for a description of the hostport parameter, and host and port results.
Types ¶
type Adapter ¶
type Adapter interface { // functions used to connect/disconnect to/from an access point ConnectToAccessPoint(ssid, pass string, timeout time.Duration) error Disconnect() error GetClientIP() (string, error) // these functions are used once the adapter is connected to the network GetDNS(domain string) (string, error) ConnectTCPSocket(addr, port string) error ConnectSSLSocket(addr, port string) error ConnectUDPSocket(addr, sendport, listenport string) error DisconnectSocket() error StartSocketSend(size int) error Write(b []byte) (n int, err error) ReadSocket(b []byte) (n int, err error) IsSocketDataAvailable() bool // FIXME: this is really specific to espat, and maybe shouldn't be part // of the driver interface Response(timeout int) ([]byte, error) }
Adapter interface is used to communicate with the network adapter.
var ActiveDevice Adapter
type Addr ¶
type Addr interface { Network() string // name of the network (for example, "tcp", "udp") String() string // string form of address (for example, "192.0.2.1:25", "[2001:db8::1]:80") }
Addr represents a network end point address.
type Conn ¶
type Conn interface { // Read reads data from the connection. // Read can be made to time out and return an Error with Timeout() == true // after a fixed time limit; see SetDeadline and SetReadDeadline. Read(b []byte) (n int, err error) // Write writes data to the connection. // Write can be made to time out and return an Error with Timeout() == true // after a fixed time limit; see SetDeadline and SetWriteDeadline. Write(b []byte) (n int, err error) // Close closes the connection. // Any blocked Read or Write operations will be unblocked and return errors. Close() error // LocalAddr returns the local network address. LocalAddr() Addr // RemoteAddr returns the remote network address. RemoteAddr() Addr // SetDeadline sets the read and write deadlines associated // with the connection. It is equivalent to calling both // SetReadDeadline and SetWriteDeadline. // // A deadline is an absolute time after which I/O operations // fail with a timeout (see type Error) instead of // blocking. The deadline applies to all future and pending // I/O, not just the immediately following call to Read or // Write. After a deadline has been exceeded, the connection // can be refreshed by setting a deadline in the future. // // An idle timeout can be implemented by repeatedly extending // the deadline after successful Read or Write calls. // // A zero value for t means I/O operations will not time out. SetDeadline(t time.Time) error // SetReadDeadline sets the deadline for future Read calls // and any currently-blocked Read call. // A zero value for t means Read will not time out. SetReadDeadline(t time.Time) error // SetWriteDeadline sets the deadline for future Write calls // and any currently-blocked Write call. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. // A zero value for t means Write will not time out. SetWriteDeadline(t time.Time) error }
Conn is a generic stream-oriented network connection. This interface is from the Go standard library.
type IP ¶
type IP []byte
IP is an IP address. Unlike the standard implementation, it is only a buffer of bytes that contains the string form of the IP address, not the full byte format used by the Go standard .
type SerialConn ¶
type SerialConn struct {
Adaptor Adapter
}
SerialConn is a loosely net.Conn compatible implementation
func (*SerialConn) Close ¶
func (c *SerialConn) Close() error
Close closes the connection. Currently only supports a single Read or Write operations without blocking.
func (*SerialConn) Read ¶
func (c *SerialConn) Read(b []byte) (n int, err error)
Read reads data from the connection. TODO: implement the full method functionality: Read can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*SerialConn) SetDeadline ¶
func (c *SerialConn) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*SerialConn) SetReadDeadline ¶
func (c *SerialConn) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*SerialConn) SetWriteDeadline ¶
func (c *SerialConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.
func (*SerialConn) Write ¶
func (c *SerialConn) Write(b []byte) (n int, err error)
Write writes data to the connection. TODO: implement the full method functionality for timeouts. Write can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.
type TCPAddr ¶
TCPAddr here to serve as compatible type. until TinyGo can compile the net package.
func ResolveTCPAddr ¶
ResolveTCPAddr returns an address of TCP end point.
The network must be a TCP network name.
type TCPSerialConn ¶
type TCPSerialConn struct { SerialConn // contains filtered or unexported fields }
TCPSerialConn is a loosely net.Conn compatible intended to support TCP over serial.
func DialTCP ¶
func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPSerialConn, error)
DialTCP makes a TCP network connection. raadr is the port that the messages will be sent to, and laddr is the port that will be listened to in order to receive incoming messages.
func NewTCPSerialConn ¶
func NewTCPSerialConn(c SerialConn, laddr, raddr *TCPAddr) *TCPSerialConn
NewTCPSerialConn returns a new TCPSerialConn/
func (*TCPSerialConn) LocalAddr ¶
func (c *TCPSerialConn) LocalAddr() Addr
LocalAddr returns the local network address.
func (*TCPSerialConn) RemoteAddr ¶
func (c *TCPSerialConn) RemoteAddr() Addr
RemoteAddr returns the remote network address.
type UDPAddr ¶
UDPAddr here to serve as compatible type. until TinyGo can compile the net package.
func ResolveUDPAddr ¶
ResolveUDPAddr returns an address of UDP end point.
The network must be a UDP network name.
type UDPSerialConn ¶
type UDPSerialConn struct { SerialConn // contains filtered or unexported fields }
UDPSerialConn is a loosely net.Conn compatible intended to support UDP over serial.
func DialUDP ¶
func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPSerialConn, error)
DialUDP makes a UDP network connection. raadr is the port that the messages will be sent to, and laddr is the port that will be listened to in order to receive incoming messages.
func ListenUDP ¶
func ListenUDP(network string, laddr *UDPAddr) (*UDPSerialConn, error)
ListenUDP listens for UDP connections on the port listed in laddr.
func NewUDPSerialConn ¶
func NewUDPSerialConn(c SerialConn, laddr, raddr *UDPAddr) *UDPSerialConn
NewUDPSerialConn returns a new UDPSerialConn/
func (*UDPSerialConn) LocalAddr ¶
func (c *UDPSerialConn) LocalAddr() Addr
LocalAddr returns the local network address.
func (*UDPSerialConn) RemoteAddr ¶
func (c *UDPSerialConn) RemoteAddr() Addr
RemoteAddr returns the remote network address.
Directories ¶
Path | Synopsis |
---|---|
cookiejar
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
|
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar. |
Package mqtt is intended to provide compatible interfaces with the Paho mqtt library.
|
Package mqtt is intended to provide compatible interfaces with the Paho mqtt library. |
Package tls is intended to provide a minimal set of compatible interfaces with the Go standard library's tls package.
|
Package tls is intended to provide a minimal set of compatible interfaces with the Go standard library's tls package. |