TsgcWebSocketHTTPServerMethods › ReStart

ReStart Method

Stops and then restarts the server from a secondary thread, useful after changing bindings or ports at runtime.

Syntax

public void ReStart();

Remarks

ReStart chains a Stop followed by a Start inside an internal worker thread, so the caller is not blocked while connections are closed and bindings reopened. It is the recommended way to apply configuration changes that require the server to re-bind its HTTP, HTTPS or HTTP/2 sockets at runtime. The OnShutdown event fires once the old listener stops, and OnStartup fires again once the new listener is accepting connections. When changing Port or Bindings, call Bindings.Clear after stopping so the old bindings are not reused.

Example


oServer.Port = 8080;
oServer.ReStart();

Back to Methods