TsgcSTUNServerMethods › RemoveBinding

RemoveBinding Method

Removes a previously added listening endpoint and closes its socket without stopping the STUN server.

Syntax

function RemoveBinding(const aIPAddress: string; aPort: Integer): Boolean;

Parameters

NameTypeDescription
aIPAddressconst stringLocal IP address of the binding to remove. Must match the value previously passed to AddBinding (or the Host of the default binding).
aPortIntegerLocal UDP port of the binding to remove.

Return Value

True when a matching endpoint was found and removed; False when no binding with the supplied IP/port exists. (Boolean)

Remarks

RemoveBinding is the runtime counterpart of AddBinding: it stops the listener thread attached to the matching endpoint, closes its UDP socket and removes the entry from the internal Bindings collection, while the remaining endpoints keep serving STUN requests unchanged. It is typically used to drop a redundant interface, rotate the listening port without calling ReStart, or tear down a secondary address once it is no longer needed. When no entry matches the supplied IP/port the server is left untouched and the method returns False.

Example

if not oSTUN.RemoveBinding('0.0.0.0', 3478) then
  ShowMessage('STUN binding not found');

Back to Methods