TsgcUDPServer › Methods › RemoveBinding
Removes the listening endpoint matching the given IP/port and closes its socket without stopping the 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 an IP previously passed to AddBinding (or the IP of an existing Bindings entry). |
aPort | Integer | Local UDP port of the binding to remove. |
True when a matching binding was found and removed; False when no entry with the supplied IP and port exists. (Boolean)
RemoveBinding stops the listener thread for the matching endpoint, closes the datagram socket and deletes the entry from Bindings, without affecting any other binding served by the component. It is the runtime counterpart of AddBinding and is typically used to drop a redundant interface or to rotate the listening port without calling ReStart. The method requires Indy 10.2 or later and raises an exception on older versions. If no matching binding is found the server is left unchanged and the method returns False.
if not oServer.RemoveBinding('0.0.0.0', 5000) then
ShowMessage('Binding not found');