TsgcTURNServerMethods › AddBinding

AddBinding Method

Adds an extra listening endpoint (IP/port) to the TURN server without stopping the bindings already in place.

Syntax

function AddBinding(const aIPAddress: string; aPort: Integer) : TIdSocketHandle;

Parameters

NameTypeDescription
aIPAddressconst stringLocal IPv4/IPv6 address to bind to. Use an empty string, 0.0.0.0 or :: to listen on every interface.
aPortIntegerLocal UDP port (1 to 65535) on which the TURN server accepts client requests. Use 3478 to match the IANA-reserved TURN port.

Return Value

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)

Remarks

AddBinding adds a listening endpoint to the server while Active is True, without stopping any binding already in place. Use it to expose the TURN service on several interfaces (for example IPv4 and IPv6 on the same host) or to accept clients on an alternate port. Each additional endpoint receives the full TURN method set (ALLOCATE, REFRESH, CREATE-PERMISSION, CHANNEL-BIND, Send/Data indications and ChannelData) plus plain STUN Binding Requests. When the supplied IP/port is already bound the existing handle is returned and no additional socket is opened. The relay ports assigned to individual Allocations are not affected by this call — they are drawn from the TURNOptions.Allocation.MinPort–MaxPort range.

Example

oTURN.AddBinding('0.0.0.0', 3478);
oTURN.AddBinding('::', 3478);
oTURN.Active := True;

Back to Methods