UDP Client
Send and receive UDP datagrams from Delphi/C++Builder. Unicast, broadcast and multicast support, plus the optional reliable-UDP overlay used by the WebRTC stack.
Send and receive UDP datagrams from Delphi/C++Builder. Unicast, broadcast and multicast support, plus the optional reliable-UDP overlay used by the WebRTC stack.
High-performance UDP datagram client — the foundation under STUN, TURN, ICE, RTCPeerConnection and any custom UDP protocol you write.
TsgcUDPClient
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Set Host / Port, Active := True, then call WriteData with the bytes you want to send. Inbound datagrams arrive on OnMessage.
uses
sgcP2P;
var
UDP: TsgcUDPClient;
begin
UDP := TsgcUDPClient.Create(nil);
UDP.Host := '127.0.0.1';
UDP.Port := 4000;
UDP.OnMessage := procedure(Connection: TsgcUDPConnection;
const aText: string)
begin
Memo1.Lines.Add(aText);
end;
UDP.Active := True;
UDP.WriteData('hello over UDP');
end;
// uses: sgcP2P
TsgcUDPClient *UDP = new TsgcUDPClient(this);
UDP->Host = "127.0.0.1";
UDP->Port = 4000;
UDP->Active = true;
UDP->WriteData("hello over UDP");
A thin, predictable UDP socket layer used as the transport for STUN / TURN / ICE / WebRTC and any custom datagram protocol.
WriteData(text) and WriteData(bytes) queue an outbound datagram. OnMessage / OnBinary deliver inbound packets with the originating endpoint.
Set Broadcast := True to enable broadcast addressing. WriteData to 255.255.255.255 reaches every host on the local subnet.
JoinMulticastGroup(addr) / LeaveMulticastGroup(addr) attach the socket to one or more multicast groups; outbound packets to those addresses fan out to every subscribed peer.
Set LocalPort / LocalHost to fix the source endpoint — required for STUN/TURN allocations and for NAT traversal symmetry.
IP version is auto-detected from the host literal. Configure IPVersion explicitly when you need to force AAAA / IPv6 paths.
Every higher P2P component (TsgcSTUNClient, TsgcTURNClient, TsgcICEClient, TsgcRTCPeerConnection) uses this client internally as its UDP transport.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — TsgcUDPClient Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\35.P2P\01.UDP_Server_Client 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 |