TsgcWebSocketServer | Start Server

The first you must set when you want start a Server is set a Listening Port, by default, this is set to port 80 but you can change for any port.

Once the port is set, there are 2 methods to start a server.

 

Active Property

If you set Active property to true, server will start to listening all incoming connection on port set.


oServer = new TsgcWebSocketServer();
oServer.Port = 80;
oServer.Active = true;

If you set Active property to false, server will stop and close all active connections.

 


oServer.Active = false;

 

Start / Stop methods

 

While if you call Active property the process of start / stop server is done in the same thread, calling Start and Stop methods will be executed in a secondary thread.

 


oServer = new TsgcWebSocketServer();
oServer.Port = 80;
oServer.Start();

If you call Stop() method, 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.