TsgcWebSocketHTTPServerProperties › KeepAlive

KeepAlive Property

Keeps the HTTP connection open after a response has been sent so that subsequent requests can reuse it.

Syntax

property KeepAlive: Boolean read GetKeepAlive write SetKeepAlive;

Default Value

True

Remarks

When KeepAlive is True the HTTP server reuses the same TCP connection for follow-up requests from the same client instead of closing it after each response. This matches HTTP/1.1 semantics and dramatically reduces connection setup cost for pages that load many resources. Set KeepAlive to False to close the socket after every response (HTTP/1.0 style). The setting is independent from WebSocket upgrade negotiation, which always keeps the connection open.

Example


oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.Port := 80;
oServer.KeepAlive := true;
oServer.Active := true;

Back to Properties