udpconn

package
v0.0.0-...-379887d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

udpconn implements Accept()-like semantics for a UDP listener

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func (*Conn) Addr

func (conn *Conn) Addr() *net.UDPAddr

Addr returns the remote address. Meaningless if called on a broadcast socket.

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) LocalAddr

func (conn *Conn) LocalAddr() *net.UDPAddr

func (*Conn) Read

func (conn *Conn) Read(p []byte) (int, error)

func (*Conn) SetSendAddress

func (conn *Conn) SetSendAddress(addr *net.UDPAddr)

SetSendAddress overrides the address that the connection sends to. This is used to handle CMD_ORIGIN_TAG.

func (*Conn) Write

func (conn *Conn) Write(p []byte) (int, error)

type Listener

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

Listener holds all the UDP sockets we're listening on. We need a bunch of sockets. One socket on INADDR_ANY with a random port to send beacons from For each interface,

Listen on addr:5076
  IP_MULTICAST_IF 127.0.0.1
  IP_MULTICAST_LOOP 1
Listen on broadcast:5076 (if interface has broadcast flag)

One socket listening on 224.0.0.128 on lo

Listen on 224.0.0.128:5076
IP_ADD_MEMBERSHIP 224.0.0.128, 127.0.0.1

func Listen

func Listen(ctx context.Context) (*Listener, error)

func (*Listener) Accept

func (ln *Listener) Accept() (*Conn, error)

func (*Listener) BroadcastConn

func (ln *Listener) BroadcastConn() *Conn

func (*Listener) BroadcastSendAddresses

func (ln *Listener) BroadcastSendAddresses() []*net.UDPAddr

func (*Listener) Close

func (ln *Listener) Close() (err error)

func (*Listener) IsTappedIP

func (ln *Listener) IsTappedIP(ip net.IP) bool

func (*Listener) LocalAddr

func (ln *Listener) LocalAddr() *net.UDPAddr

func (*Listener) WriteMulticast

func (ln *Listener) WriteMulticast(p []byte) (int, error)

Jump to

Keyboard shortcuts

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