TURN Client
Talk to a TURN server from Delphi/C++Builder. Allocate relayed transport addresses, manage permissions and channels, then exchange data with peers behind symmetric NAT — per RFC 8656.
Talk to a TURN server from Delphi/C++Builder. Allocate relayed transport addresses, manage permissions and channels, then exchange data with peers behind symmetric NAT — per RFC 8656.
TURN client — Allocate, CreatePermission, ChannelBind, Send / Indication / Data, Refresh, all signed with long-term credentials per RFC 8656.
TsgcTURNClient
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
Set TURN server / username / password, call Allocate, then CreatePermission for each peer and Send / SendIndication to relay data.
uses
sgcP2P;
var
TURN: TsgcTURNClient;
begin
TURN := TsgcTURNClient.Create(nil);
TURN.Host := 'turn.example.com';
TURN.Port := 3478;
TURN.Authentication.UserName := 'alice';
TURN.Authentication.Password := 'secret';
TURN.OnTURNAllocated := procedure(Sender: TObject;
const aRelayedAddress, aRelayedPort: string)
begin
Memo1.Lines.Add('relay: ' + aRelayedAddress + ':' + aRelayedPort);
TURN.CreatePermission('192.0.2.1');
TURN.SendIndication('192.0.2.1', 5000, 'hello via TURN');
end;
TURN.Allocate;
end;
// uses: sgcP2P
TsgcTURNClient *TURN = new TsgcTURNClient(this);
TURN->Host = "turn.example.com";
TURN->Port = 3478;
TURN->Authentication->UserName = "alice";
TURN->Authentication->Password = "secret";
TURN->Allocate();
A typed RFC 8656 TURN client — the relay layer for WebRTC when STUN-only NAT traversal fails.
Allocate sends Allocate request with REQUESTED-TRANSPORT (UDP, TCP) and obtains a relayed transport address. Refresh extends the lifetime; Free deallocates explicitly.
CreatePermission(peerIp) registers a peer whose datagrams the relay will forward. Permissions auto-expire after 5 minutes — refresh as needed.
ChannelBind(channelNumber, peerEndpoint) bypasses the 36-byte Send/Data overhead. The component encodes the 4-byte ChannelData header automatically.
Authentication.UserName / Password populate MESSAGE-INTEGRITY using the realm and nonce extracted from the 401 challenge.
Set the underlying client's Transport to TCP or TLS for environments that block UDP — RFC 6062 / 6056 transport choices are supported.
TsgcRTCPeerConnection consumes TsgcTURNClient as one of its IceServers — the Allocate, CreatePermission and ChannelBind dance happens transparently.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — TsgcTURNClient Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\35.P2P\03.TURN Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |