sgcWebSockets · Technical Document

UDP Client

TsgcUDPClient — low-level UDP datagram client for sgcWebSockets P2P stack; foundation for STUN, TURN and ICE.

Overview

TsgcUDPClient implements the UDP Client based on Indy library.

At a glance

Component class
TsgcUDPClient
Standards / spec
UDP — RFC 768
Transports
TCP, TLS
Platforms
Windows, macOS, Linux, iOS, Android
Frameworks
VCL, FireMonkey, Lazarus / FPC
Edition
Standard / Professional / Enterprise

Features

Technical specification

Standards & specsUDP — RFC 768
Component classTsgcUDPClient (unit sgcUDP_Client)
FrameworksVCL, FireMonkey, Lazarus / FPC
PlatformsWindows, macOS, Linux, iOS, Android

Main properties

The principal published / public properties used to configure and drive the component. Consult the online help for the full list.

DTLSOptionsCertificate, verification and OpenSSL settings applied when DTLS is enabled.
HostIP address or DNS hostname of the destination UDP peer or server.
PortUDP port number of the destination peer or server.
DTLSEnables Datagram TLS (DTLS) to encrypt the UDP traffic sent and received by this client.
ProxyOptional SOCKS5 proxy through which UDP datagrams are tunneled.
LogFileWrites every datagram sent and received to a plain-text log file for diagnostics.
NotifyEventsControls how received-datagram and exception events are dispatched to the main thread.
IPVersionSelects the IP stack (IPv4 or IPv6) used by the UDP socket.
VersionRead-only string with the sgcWebSockets library version that built this component.

Main methods

The principal public methods exposed by the component.

WriteData()Sends a single UDP datagram (overloaded for text, bytes and explicit address/port).
ClearDTLS()Discards the cached DTLS session state so the next datagram triggers a fresh DTLS handshake.

Public events

The component exposes the following published events; consult the online help for full event-handler signatures.

OnDTLSVerifyPeerFires during the DTLS handshake so the application can inspect and accept or reject the peer certificate.
OnUDPExceptionFires when the UDP reader thread catches an unhandled exception.
OnUDPReadFires when an incoming UDP datagram has been received from the peer.

Quick Start

Drop the component on a form, configure the properties below and activate it. The snippet that follows shows the typical TsgcUDPCLient configuration sourced from the online help.

About this scenario. TsgcUDPClient implements the UDP Client based on Indy library.

Delphi (VCL / FireMonkey)

oClient := TsgcUDPClient.Create(nil);
    oClient.Host := '127.0.0.1';
    oClient.Port := 80;

C++ Builder

oClient = new TsgcUDPCLient();
    oClient->Host = "127.0.0.1";
    oClient->Port = 80;

.NET (C#)

oClient = new TsgcUDPCLient();
    oClient.Host = "127.0.0.1";
    oClient.Port = 80;

Common scenarios

The following scenarios are lifted verbatim from the online help. Each shows the configuration and method calls needed to drive the component through a specific real-world flow.

1 · TsgcUDPServer

TsgcUDPServer implements the UDP Server based on Indy library.

Delphi (VCL / FireMonkey)
oClient := TsgcUDPServer.Create(nil);
    oClient.Port := 80;
C++ Builder
oClient = new TsgcUDPServer();
    oClient->Port = 80;
.NET (C#)
oClient = new TsgcUDPServer();
    oClient.Port = 80;

Sources used to build this document

Every external claim links back to a primary source. The online-help references decode the canonical deep-link the company maintains for this component.

Document scope. This document covers the publicly-documented surface of the UDP Client component shipped with sgcWebSockets. For full property, method and event reference consult the online help linked above.