TsgcQUICServer › Methods › WriteData

WriteData Method

Sends application bytes to a connected peer over its default QUIC stream.

Syntax

procedure WriteData(const aConnection: TsgcQUICServerConnection; const aData: TBytes);

Parameters

NameTypeDescription
aConnectionconst TsgcQUICServerConnectionTarget connection, typically the Connection passed to an event handler such as OnQUICConnect or OnQUICData.
aDataconst TBytesBytes to send to the peer over its default QUIC stream.

Remarks

Writes the supplied bytes to the peer-initiated default stream that was accepted for the connection. Because that stream is opened by the peer, data cannot be written before the peer has opened it, which is why OnQUICConnect is deferred until the first stream is ready; calling WriteData from that event (or from OnQUICData) is always safe. The call is non-blocking: the bytes are queued and flushed through the QUIC event loop. To use additional or server-initiated streams, open them with OpenStream and write with WriteStreamData instead.

Example


procedure OnQUICDataEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aData: TBytes);
begin
  // echo the received bytes back to the peer
  oServer.WriteData(aConnection, aData);
end;

Back to Methods