TsgcQUICServer › Methods › WriteData
Sends application bytes to a connected peer over its default QUIC stream.
procedure WriteData(const aConnection: TsgcQUICServerConnection; const aData: TBytes);
| Name | Type | Description |
|---|---|---|
aConnection | const TsgcQUICServerConnection | Target connection, typically the Connection passed to an event handler such as OnQUICConnect or OnQUICData. |
aData | const TBytes | Bytes to send to the peer over its default QUIC stream. |
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.
procedure OnQUICDataEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aData: TBytes);
begin
// echo the received bytes back to the peer
oServer.WriteData(aConnection, aData);
end;