socket

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SocketReadDeadline = 10 * time.Millisecond
)

Variables

This section is empty.

Functions

func CreateSocketReader

func CreateSocketReader(protocol string, addr string, port uint16) (io.ReadCloser, error)

func CreateSocketWriter

func CreateSocketWriter(protocol string, addr string, port uint16) (io.WriteCloser, error)

func NewTCPSocketReader

func NewTCPSocketReader(addr string, port uint16) (io.ReadCloser, error)

func NewTCPSocketWriter

func NewTCPSocketWriter(addr string, port uint16) (io.WriteCloser, error)

func NewUDPSocketReader

func NewUDPSocketReader(addr string, port uint16) (io.ReadCloser, error)

func NewUDPSocketWriter

func NewUDPSocketWriter(addr string, port uint16) (io.WriteCloser, error)

Types

type TCPTimeoutReader

type TCPTimeoutReader struct {
	Listener *net.TCPListener
	Conns    []*net.TCPConn
	// contains filtered or unexported fields
}

func (TCPTimeoutReader) Close

func (r TCPTimeoutReader) Close() error

Close all connections then the listener. Only the first occurring error will be returned.

func (*TCPTimeoutReader) Read

func (r *TCPTimeoutReader) Read(b []byte) (n int, err error)

Firstly calls [acceptWaitingConnections]. Then wraps the read with a deadline to timeout the Read attempt if there is no incoming data. Timeout used is SocketReadDeadline. Removes any connections that have been closed.

type UDPTimeoutReader

type UDPTimeoutReader struct {
	Conn *net.UDPConn
}

func (UDPTimeoutReader) Close

func (r UDPTimeoutReader) Close() error

func (UDPTimeoutReader) Read

func (r UDPTimeoutReader) Read(b []byte) (n int, err error)

Wraps the read with a deadline to timeout the Read attempt if there is no incoming data. Timeout used is SocketReadDeadline.

Jump to

Keyboard shortcuts

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