TsgcQUICServer › Events › OnStartup

OnStartup Event

Fires when the server has started listening for QUIC connections.

Syntax

property OnStartup: TNotifyEvent;
// TNotifyEvent = procedure(Sender: TObject) of object

Default Value

—

Remarks

OnStartup is published and inherited from the UDP server base class, and the QUIC server raises it once the listener has been bound and the background thread that drives the QUIC event loop is running. So when the handler runs, the server is already accepting connections.

It is raised from Start (equally from Active := True, which is what Start does), on the caller's thread, before Start returns. A failed start raises an exception instead of firing this event, so the handler only runs on a successful bring-up. Starting an already started server does nothing and does not raise it again.

Handling this event and putting your code after Start returns are equivalent, so use whichever suits your design. The event is the more convenient of the two when the server is started from somewhere else in your code, or from a component you do not control.

In the .NET implementation OnStartup is raised at the end of Start() in the same way, so a handler behaves the same in both languages.

Example


// Raised once the listener is bound and accepting:
procedure OnStartup(Sender: TObject);
begin
  WriteLn('#QUIC server started');
end;

// Assign it before starting the server
oServer.OnStartup := OnStartup;
try
  oServer.Start;
except
  on E: Exception do
    WriteLn('#QUIC server failed to start: ' + E.Message);
end;

Back to Events