TsgcSTUNServer › Methods › AddBinding
Adds an extra listening endpoint (IP/port) to the STUN server without restarting the currently active bindings.
function AddBinding(const aIPAddress: string; aPort: Integer) : TIdSocketHandle;
| Name | Type | Description |
|---|---|---|
aIPAddress | const string | Local IPv4/IPv6 address to bind to. Use an empty string, 0.0.0.0 or :: to listen on every interface. |
aPort | Integer | Local UDP port (1 to 65535) on which the STUN server accepts Binding Requests. Use 3478 to match the IANA-reserved STUN port. |
The newly created TIdSocketHandle, or the existing one when an entry for the same IP/port is already present. The handle is owned by the internal Bindings collection and must not be freed by the caller. (TIdSocketHandle)
AddBinding adds a listening endpoint to the server while Active is True, without stopping any binding already in place. Use it to expose the STUN service on several interfaces (for example IPv4 and IPv6 on the same host), or to enable the OTHER-ADDRESS attribute that requires the server to be reachable on a second address/port. When the supplied IP/port is already bound the existing handle is returned and no additional socket is opened. The OTHER-ADDRESS / RESPONSE-ORIGIN attributes produced in successful Binding Responses are derived from the set of active bindings.
oSTUN.AddBinding('0.0.0.0', 3478);
oSTUN.AddBinding('::', 3478);
oSTUN.Active := True;