Delphi ICE Client

Run the full ICE algorithm in Delphi/C++Builder — gather host, server-reflexive and relay candidates, perform STUN connectivity checks, nominate the best pair per RFC 8445.

TsgcICEClient

Implements the RFC 8445 ICE state machine — candidate gathering, prioritisation, pair generation, connectivity checks (BindingRequest with USE-CANDIDATE), nomination and consent freshness.

Component class

TsgcICEClient

Protocol

ICE (RFC 8445)

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Enterprise

Configure servers, gather, exchange, check

Configure STUN/TURN ICE servers, call GatherCandidates, exchange the candidate list with the peer (out of band), then ProcessCandidates to run the checks and nominate a working pair.

uses
  sgcP2P, sgcP2P_ICE_Classes;

// TFormICE holds FClient: TsgcICEClient and FLog: TStringList

procedure TFormICE.Gather;
begin
  FClient := TsgcICEClient.Create(nil);
  FClient.ICEServers.AddURL('stun:stun.l.google.com:19302');
  FClient.ICEServers.AddURL('turn:turn.example.com', 'alice', 'secret');

  FClient.OnICECandidate := OnICECandidate;
  FClient.OnICECandidatePairNominated := OnICECandidatePairNominated;

  FClient.GatherCandidates;
end;

procedure TFormICE.OnICECandidate(Sender: TObject;
  const aCandidate: TsgcICE_Candidate);
begin
  // AsString is the candidate line, ready for your signalling channel
  SignalToPeer(aCandidate.AsString);
end;

// remote candidates arrive over your signalling channel
procedure TFormICE.AddRemoteCandidate(const aCandidate: string);
begin
  FClient.AddRTCIceCandidate(aCandidate);
  FClient.ProcessCandidates;
end;

procedure TFormICE.OnICECandidatePairNominated(Sender: TObject;
  const aCandidatePair: TsgcICE_CandidatePair);
begin
  FLog.Add('nominated: ' + aCandidatePair.Local.Address + ' -> ' +
    aCandidatePair.Remote.Address);
end;
// includes: sgcP2P.hpp, sgcP2P_ICE_Classes.hpp
TsgcICEClient *Client = new TsgcICEClient(this);
Client->ICEServers->AddURL("stun:stun.l.google.com:19302");
Client->OnICECandidate = OnICECandidate;
Client->GatherCandidates();

What's inside

A reusable ICE engine that drops below TsgcRTCPeerConnection — or runs on its own for non-WebRTC P2P.

Candidate gathering

Enumerates host candidates from every local interface, server-reflexive candidates from each STUN server, relayed candidates from each TURN server — all in parallel.

Pair generation & prioritisation

Computes the candidate-pair priorities per RFC 8445 §6.1.2 and orders the check list. Frozen pairs unfreeze as their foundation makes progress.

Connectivity checks

Sends STUN BindingRequests with PRIORITY, ICE-CONTROLLING / ICE-CONTROLLED, USE-CANDIDATE attributes per the standard. Triggered checks fire on inbound stimulus.

Nomination

When a pair succeeds and the controlling agent flags USE-CANDIDATE, the component fires OnICECandidatePairNominated with the pair that won, and aCandidatePair.Local / Remote tell you which two addresses it picked.

Implements RFC 7675 consent-freshness probes: a Binding request on the nominated pair every ConsentInterval milliseconds, and OnICECandidatePairFailed with the reason Consent Freshness Timeout once ConsentTimeout passes with no answer.

Signalling-agnostic

The component assumes no particular signalling channel. You put aCandidate.AsString on your WebSocket, SIP or HTTP signalling, and feed what comes back to AddRTCIceCandidate followed by ProcessCandidates.

Specifications & references

Authoritative sources for the protocol this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — TsgcICEClient Full property, method and event reference for this component.
Demo Project — Demos\35.P2P\04.ICE Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Run ICE in Delphi?

Download the free trial and add full ICE candidate gathering and connectivity checks to your Delphi applications.