Documentation ¶
Index ¶
- Variables
- func IsIPv6(addr net.IP) bool
- func WithErrors(v func(err error)) errorsOpt
- func WithHeartBeat(v time.Duration) heartBeat
- func WriteToUDP(conn *net.UDPConn, raddr *net.UDPAddr, b []byte) (int, error)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Connection() net.Conn
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) ReadFullWithContext(ctx context.Context, buffer []byte) error
- func (c *Conn) ReadWithContext(ctx context.Context, buffer []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) WriteWithContext(ctx context.Context, data []byte) error
- type ConnOption
- type ControlMessage
- type DTLSListener
- type DTLSListenerOption
- type TCPListener
- type TCPListenerOption
- type TLSListener
- type TLSListenerOption
- type UDPConn
- func (c *UDPConn) Close() error
- func (c *UDPConn) JoinGroup(ifi *net.Interface, group net.Addr) error
- func (c *UDPConn) LeaveGroup(ifi *net.Interface, group net.Addr) error
- func (c *UDPConn) LocalAddr() net.Addr
- func (c *UDPConn) Network() string
- func (c *UDPConn) ReadWithContext(ctx context.Context, buffer []byte) (int, *net.UDPAddr, error)
- func (c *UDPConn) RemoteAddr() net.Addr
- func (c *UDPConn) SetMulticastLoopback(on bool) error
- func (c *UDPConn) WriteMulticast(ctx context.Context, raddr *net.UDPAddr, hopLimit int, buffer []byte) error
- func (c *UDPConn) WriteWithContext(ctx context.Context, raddr *net.UDPAddr, buffer []byte) error
- type UDPOption
Constants ¶
This section is empty.
Variables ¶
var ErrListenerIsClosed = errors.New("listen socket was closed")
Functions ¶
func WithErrors ¶
func WithErrors(v func(err error)) errorsOpt
func WithHeartBeat ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a generic stream-oriented network connection that provides Read/Write with context.
Multiple goroutines may invoke methods on a Conn simultaneously.
func NewConn ¶
func NewConn(c net.Conn, opts ...ConnOption) *Conn
NewConn creates connection over net.Conn.
func (*Conn) Connection ¶
Connection returns the network connection. The Conn returned is shared by all invocations of Connection, so do not modify it.
func (*Conn) LocalAddr ¶
LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.
func (*Conn) ReadFullWithContext ¶
ReadFullWithContext reads stream with context until whole buffer is satisfied.
func (*Conn) ReadWithContext ¶
ReadWithContext reads stream with context.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.
type ConnOption ¶
type ConnOption interface {
// contains filtered or unexported methods
}
A ConnOption sets options such as heartBeat, errors parameters, etc.
type ControlMessage ¶
type DTLSListener ¶
type DTLSListener struct {
// contains filtered or unexported fields
}
DTLSListener is a DTLS listener that provides accept with context.
func NewDTLSListener ¶
func NewDTLSListener(network string, addr string, dtlsCfg *dtls.Config, opts ...DTLSListenerOption) (*DTLSListener, error)
NewDTLSListener creates dtls listener. Known networks are "udp", "udp4" (IPv4-only), "udp6" (IPv6-only).
func (*DTLSListener) Accept ¶
func (l *DTLSListener) Accept() (net.Conn, error)
Accept waits for a generic Conn.
func (*DTLSListener) AcceptWithContext ¶
AcceptWithContext waits with context for a generic Conn.
func (*DTLSListener) Addr ¶
func (l *DTLSListener) Addr() net.Addr
Addr represents a network end point address.
func (*DTLSListener) SetDeadline ¶
func (l *DTLSListener) SetDeadline(t time.Time) error
SetDeadline sets deadline for accept operation.
type DTLSListenerOption ¶
type DTLSListenerOption interface {
// contains filtered or unexported methods
}
A DTLSListenerOption sets options such as heartBeat parameters, etc.
type TCPListener ¶
type TCPListener struct {
// contains filtered or unexported fields
}
TCPListener is a TCP network listener that provides accept with context.
func NewTCPListener ¶
func NewTCPListener(network string, addr string, opts ...TCPListenerOption) (*TCPListener, error)
NewTCPListener creates tcp listener. Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only).
func (*TCPListener) Accept ¶
func (l *TCPListener) Accept() (net.Conn, error)
Accept waits for a generic Conn.
func (*TCPListener) AcceptWithContext ¶
AcceptWithContext waits with context for a generic Conn.
func (*TCPListener) Addr ¶
func (l *TCPListener) Addr() net.Addr
Addr represents a network end point address.
func (*TCPListener) SetDeadline ¶
func (l *TCPListener) SetDeadline(t time.Time) error
SetDeadline sets deadline for accept operation.
type TCPListenerOption ¶
type TCPListenerOption interface {
// contains filtered or unexported methods
}
A TCPListenerOption sets options such as heartBeat parameters, etc.
type TLSListener ¶
type TLSListener struct {
// contains filtered or unexported fields
}
TLSListener is a TLS listener that provides accept with context.
func NewTLSListener ¶
func NewTLSListener(network string, addr string, tlsCfg *tls.Config, opts ...TLSListenerOption) (*TLSListener, error)
NewTLSListener creates tcp listener. Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only).
func (*TLSListener) Accept ¶
func (l *TLSListener) Accept() (net.Conn, error)
Accept waits for a generic Conn.
func (*TLSListener) AcceptWithContext ¶
AcceptWithContext waits with context for a generic Conn.
func (*TLSListener) Addr ¶
func (l *TLSListener) Addr() net.Addr
Addr represents a network end point address.
func (*TLSListener) SetDeadline ¶
func (l *TLSListener) SetDeadline(t time.Time) error
SetDeadline sets deadline for accept operation.
type TLSListenerOption ¶
type TLSListenerOption interface {
// contains filtered or unexported methods
}
A TLSListenerOption sets options such as heartBeat parameters, etc.
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is a udp connection provides Read/Write with context.
Multiple goroutines may invoke methods on a UDPConn simultaneously.
func NewUDPConn ¶
NewUDPConn creates connection over net.UDPConn.
func (*UDPConn) JoinGroup ¶
JoinGroup joins the group address group on the interface ifi. By default all sources that can cast data to group are accepted. It's possible to mute and unmute data transmission from a specific source by using ExcludeSourceSpecificGroup and IncludeSourceSpecificGroup. JoinGroup uses the system assigned multicast interface when ifi is nil, although this is not recommended because the assignment depends on platforms and sometimes it might require routing configuration.
func (*UDPConn) LeaveGroup ¶
LeaveGroup leaves the group address group on the interface ifi regardless of whether the group is any-source group or source-specific group.
func (*UDPConn) LocalAddr ¶
LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.
func (*UDPConn) ReadWithContext ¶
ReadWithContext reads packet with context.
func (*UDPConn) RemoteAddr ¶
RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.
func (*UDPConn) SetMulticastLoopback ¶
SetMulticastLoopback sets whether transmitted multicast packets should be copied and send back to the originator.