Hello,
I'm managing a Server and a client and I'd like to ping the server to be sure the connexion is well established.
As a test, I've created the client before the server, and I've done a ping. An exception is thrown in a loop, because the server is not existing. How can I manage this case? I'd like to get a return value saying the connexion is not established and be able to continue.
Julien.
Checking the connexion with Ping functionality
Re: Checking the connexion with Ping functionality
Hi Julien,
Before pinging the connection, you can call ClientStub::isConnected():
RcfClient<...> client(...);
// ...
if (client.getClientStub().isConnected())
{
// ...
}
isConnected() will return false if you have not established a connection, of if there are detectable errors with an established network connection.
Before pinging the connection, you can call ClientStub::isConnected():
RcfClient<...> client(...);
// ...
if (client.getClientStub().isConnected())
{
// ...
}
isConnected() will return false if you have not established a connection, of if there are detectable errors with an established network connection.
Re: Checking the connexion with Ping functionality
Thanks !
Julien.
Julien.
Re: Checking the connexion with Ping functionality
Actually, isConnected() always returns 0. The fact I'm using Win32NamedPipe might be the issue, don't you think so ?
Here is my code to test this function:
Julien.
Here is my code to test this function:
Code: Select all
server = new (std::nothrow) RCF::RcfServer(RCF::Win32NamedPipeEndpoint(OSUP_PIPE));
server->bind<I_SUP>(*this);
server->start();
I_SupMonitoring_OSUP_Client = new RcfClient<I_SUP>(RCF::Win32NamedPipeEndpoint(OSUP_PIPE));
if(I_SupMonitoring_OSUP_Client->getClientStub().isConnected())
{
printf("OK\n");
}
Re: Checking the connexion with Ping functionality
Actually, the isConnected has to be done once a first remote call has been done. But this implementation doesn't fit my expectations: if the connection is not established, the first remote call with throw an exception. As I'm not managing the exceptions, I need to test the connection before any remote calls.
Best regards,
Julien.
Best regards,
Julien.