TECH TIP: Testing Whether the Server is Active
The following code show how to test whether the server is active.
This code uses the TrsClientTcpSocket component to connect to the server. The example shows the code within the context of a Button.OnClick event-handler. However, you could also code this to fire at a specified interval by using a TTimer component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
uses rsClientTcpSocket, rsExceptions; procedure TForm1.Button1Click(Sender: TObject); var lClientSocket: TrsClientTcpSocket; begin lClientSocket := TrsClientTcpSocket.Create; try {configur the connection parameters} {lClientSocket.Connection := rsClientReport.Connection; } try lClientSocket.Active := True; except on EClientError do ShowMessage('Server is down'); end; finally lClientSocket.Free; end; end; |