Class UdpRelayListener
Relays UDP datagrams between clients and an upstream with one session per client endpoint. A single receive loop reads the listening socket; the first datagram from a client endpoint picks an upstream (a cluster destination through the load balancer, or the fixed forward host), connects a UDP socket to it, and later datagrams from that endpoint reuse the socket. Each session has its own upstream receive loop that sends replies back through the listening socket to that client endpoint only. Idle sessions are closed by a timer wheel, so no session owns a timer. The listener has no connection to any HTTP path.
Inherited Members
Namespace: Titanium.Web.Proxy.Udp
Assembly: Titanium.Web.Proxy.dll
Syntax
public sealed class UdpRelayListener : IAsyncDisposable, IDisposable
Constructors
| Edit this page View SourceUdpRelayListener(UdpRelayOptions, ClusterManager?, LoadBalancer?)
Declaration
public UdpRelayListener(UdpRelayOptions options, ClusterManager? clusters = null, LoadBalancer? loadBalancer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UdpRelayOptions | options | Listener settings. Copy semantics: later changes to the object are not observed. |
| ClusterManager | clusters | Cluster manager that owns destination state. Required with ClusterId. |
| LoadBalancer | loadBalancer | Picks the destination for a new session. Required with ClusterId. |
Properties
| Edit this page View SourceActiveSessions
Sessions open right now.
Declaration
public int ActiveSessions { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsDraining
True after BeginDrain(). A draining listener relays existing sessions and opens no new one.
Declaration
public bool IsDraining { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LocalEndPoint
The bound address and port. Null before Start().
Declaration
public IPEndPoint? LocalEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| IPEndPoint |
Methods
| Edit this page View SourceBeginDrain()
Stops opening sessions. Datagrams on open sessions keep flowing until they go idle.
Declaration
public void BeginDrain()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
DisposeAsync()
Closes every session and the listening socket.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask |
DrainAsync(TimeSpan)
Calls BeginDrain() and waits until every session has closed or timeout
passes, whichever is first. Returns true when no session is left.
Declaration
public Task<bool> DrainAsync(TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout |
Returns
| Type | Description |
|---|---|
| Task<bool> |
Start()
Binds the socket and starts the receive loop and the idle sweep.
Declaration
public void Start()