TsgcSTUNServer › Methods › RemoveBinding
Removes a previously added listening endpoint and closes its socket without stopping the STUN server.
function RemoveBinding(const aIPAddress: string; aPort: Integer): Boolean;
| Name | Type | Description |
|---|---|---|
aIPAddress | const string | Local IP address of the binding to remove. Must match the value previously passed to AddBinding (or the Host of the default binding). |
aPort | Integer | Local UDP port of the binding to remove. |
True when a matching endpoint was found and removed; False when no binding with the supplied IP/port exists. (Boolean)
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.
if not oSTUN.RemoveBinding('0.0.0.0', 3478) then
ShowMessage('STUN binding not found');