Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientMap ¶
type ClientMap struct {
IdleTimeout time.Duration
IdleCheckInterval time.Duration
// contains filtered or unexported fields
}
ClientMap provides a goroutine-safe map of UDP connections to a remote address keyed by the client address, with a built-in idle TTL that closes and removes entries that remain idle beyond it.
func (*ClientMap) Get ¶
func (cm *ClientMap) Get( clientAddr net.Addr, remote *net.UDPAddr, handler ServerConnHandler, ) (*net.UDPConn, error)
Get gets or creates a new UDP connection to the remote server and stores it in a map, matching clients to remote server connections. This way, we keep one UDP connection open to the server for each client. The handler parameter is invoked when a new connection needs to be created (for a new client) to defer that behavior to the caller.
type ServerConnHandler ¶
Click to show internal directories.
Click to hide internal directories.