The first thing you must set when you want to start a server is the listening port. By default, this is set to port 80 but you can change it to any port.
Once the port is set, there are 2 methods to start a server.
If you set the Active property to true, the server will start listening for all incoming connections on the configured port.
oServer := TsgcWebSocketServer.Create(nil);
oServer.Port := 80;
oServer.Active := true;
If you set the Active property to false, the server will stop and close all active connections.
oServer.Active := false;
While setting the Active property starts/stops the server in the same thread, the Start and Stop methods are executed in a secondary thread.
oServer := TsgcWebSocketServer.Create(nil);
oServer.Port := 80;
oServer.Start();
If you call the Stop() method, the server will stop and close all active connections.
oServer.Stop();
You can use the method ReStart, to Stop and Start server in a secondary thread.
If you change the Port after closing a server, to start listening on a different port, call the method Bindings.Clear() after closing the server to delete all previous bindings. Otherwise the server will try to bind to the previous bindings.