TsgcSTUNClient › Methods › WriteData
Advanced: sends raw bytes over the STUN client socket, either to the connected peer or to an explicit IP/port pair.
procedure WriteData(const aBytes: TBytes);
| Name | Type | Description |
|---|---|---|
aBytes | const TBytes | Raw bytes to send; normally a pre-built STUN message. |
Sends aBytes as-is to the currently configured STUN server (see Host/Port). Use this overload to transmit a custom STUN or TURN message that you have assembled manually.
var
vBytes: TBytes;
begin
vBytes := BuildCustomStunMessage;
oSTUN.WriteData(vBytes);
end;
procedure WriteData(const aIPAddress: string; aPort: Word; const aBytes: TBytes);
| Name | Type | Description |
|---|---|---|
aIPAddress | const string | Destination IP address (IPv4 or IPv6, matching IPVersion). |
aPort | Word | Destination UDP/TCP port. |
aBytes | const TBytes | Raw bytes to send to the target endpoint. |
Sends aBytes to an arbitrary host:port pair instead of the one defined by Host/Port. Typically used in STUN check scenarios where the server replies from a different address (RFC 5780 NAT Behavior Discovery) or when reusing the same socket to reach several STUN peers.
var
vBytes: TBytes;
begin
vBytes := BuildCustomStunMessage;
oSTUN.WriteData('192.0.2.10', 3478, vBytes);
end;