udp

package
v0.0.0-...-32470e3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(localAddr string) (net.PacketConn, error)

raw bind (unconnected udp)

Connect() return a connnected udp, some 3rd package want a unconnected udp.

Types

type Client

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

func New

func New(rndzServer, id string, localAddr netip.AddrPort) *Client

New initializes a new Client with the provided rendezvous server, ID, and local address. If no local address is set, it chooses one based on the server address type (IPv4 or IPv6).

func (*Client) Close

func (c *Client) Close()

Close stops internal goroutines and closes connections.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, targetId string) (*net.UDPConn, error)

Connect sends a connection request to the rendezvous server to connect to the target peer. It returns a connected UDP connection.

func (*Client) Listen

func (c *Client) Listen(ctx context.Context) (net.PacketConn, error)

Listen starts listening for peer connection requests while pinging the rendezvous server.

Jump to

Keyboard shortcuts

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