gonet

package
v0.0.0-...-ba09d25 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gonet provides a Go net package compatible wrapper for a tcpip stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCPConn

type TCPConn struct {
	// contains filtered or unexported fields
}

A TCPConn is a wrapper around a TCP tcpip.Endpoint that implements the net.Conn interface.

func DialContextTCP

func DialContextTCP(ctx context.Context, s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*TCPConn, error)

DialContextTCP creates a new TCPConn connected to the specified address with the option of adding cancellation and timeouts.

func DialTCP

func DialTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*TCPConn, error)

DialTCP creates a new TCPConn connected to the specified address.

func DialTCPWithBind

func DialTCPWithBind(ctx context.Context, s *stack.Stack, localAddr, remoteAddr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*TCPConn, error)

DialTCPWithBind creates a new TCPConn connected to the specified remoteAddress with its local address bound to localAddr.

func NewTCPConn

func NewTCPConn(wq *waiter.Queue, ep tcpip.Endpoint) *TCPConn

NewTCPConn creates a new TCPConn.

func (*TCPConn) Close

func (c *TCPConn) Close() error

Close implements net.Conn.Close.

func (*TCPConn) CloseRead

func (c *TCPConn) CloseRead() error

CloseRead shuts down the reading side of the TCP connection. Most callers should just use Close.

A TCP Half-Close is performed the same as CloseRead for *net.TCPConn.

func (*TCPConn) CloseWrite

func (c *TCPConn) CloseWrite() error

CloseWrite shuts down the writing side of the TCP connection. Most callers should just use Close.

A TCP Half-Close is performed the same as CloseWrite for *net.TCPConn.

func (*TCPConn) LocalAddr

func (c *TCPConn) LocalAddr() net.Addr

LocalAddr implements net.Conn.LocalAddr.

func (*TCPConn) Read

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

Read implements net.Conn.Read.

func (*TCPConn) RemoteAddr

func (c *TCPConn) RemoteAddr() net.Addr

RemoteAddr implements net.Conn.RemoteAddr.

func (*TCPConn) SetDeadline

func (d *TCPConn) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.SetDeadline and net.PacketConn.SetDeadline.

func (*TCPConn) SetReadDeadline

func (d *TCPConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn.SetReadDeadline and net.PacketConn.SetReadDeadline.

func (*TCPConn) SetWriteDeadline

func (d *TCPConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn.SetWriteDeadline and net.PacketConn.SetWriteDeadline.

func (*TCPConn) Write

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

Write implements net.Conn.Write.

type TCPListener

type TCPListener struct {
	// contains filtered or unexported fields
}

A TCPListener is a wrapper around a TCP tcpip.Endpoint that implements net.Listener.

func ListenTCP

func ListenTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*TCPListener, error)

ListenTCP creates a new TCPListener.

func NewTCPListener

func NewTCPListener(s *stack.Stack, wq *waiter.Queue, ep tcpip.Endpoint) *TCPListener

NewTCPListener creates a new TCPListener from a listening tcpip.Endpoint.

func (*TCPListener) Accept

func (l *TCPListener) Accept() (net.Conn, error)

Accept implements net.Conn.Accept.

func (*TCPListener) Addr

func (l *TCPListener) Addr() net.Addr

Addr implements net.Listener.Addr.

func (*TCPListener) Close

func (l *TCPListener) Close() error

Close implements net.Listener.Close.

func (*TCPListener) Shutdown

func (l *TCPListener) Shutdown()

Shutdown stops the HTTP server.

type UDPConn

type UDPConn struct {
	// contains filtered or unexported fields
}

A UDPConn is a wrapper around a UDP tcpip.Endpoint that implements net.Conn and net.PacketConn.

func DialUDP

func DialUDP(s *stack.Stack, laddr, raddr *tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*UDPConn, error)

DialUDP creates a new UDPConn.

If laddr is nil, a local address is automatically chosen.

If raddr is nil, the UDPConn is left unconnected.

func NewUDPConn

func NewUDPConn(s *stack.Stack, wq *waiter.Queue, ep tcpip.Endpoint) *UDPConn

NewUDPConn creates a new UDPConn.

func (*UDPConn) Close

func (c *UDPConn) Close() error

Close implements net.PacketConn.Close.

func (*UDPConn) LocalAddr

func (c *UDPConn) LocalAddr() net.Addr

LocalAddr implements net.PacketConn.LocalAddr.

func (*UDPConn) Read

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

Read implements net.Conn.Read

func (*UDPConn) ReadFrom

func (c *UDPConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom implements net.PacketConn.ReadFrom.

func (*UDPConn) RemoteAddr

func (c *UDPConn) RemoteAddr() net.Addr

RemoteAddr implements net.Conn.RemoteAddr.

func (*UDPConn) SetDeadline

func (d *UDPConn) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.SetDeadline and net.PacketConn.SetDeadline.

func (*UDPConn) SetReadDeadline

func (d *UDPConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn.SetReadDeadline and net.PacketConn.SetReadDeadline.

func (*UDPConn) SetWriteDeadline

func (d *UDPConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn.SetWriteDeadline and net.PacketConn.SetWriteDeadline.

func (*UDPConn) Write

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

func (*UDPConn) WriteTo

func (c *UDPConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo implements net.PacketConn.WriteTo.

Jump to

Keyboard shortcuts

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