Checking the connexion with Ping functionality

RCF support and general discussion.
Post Reply
jponnoua
Posts: 7
Joined: Thu Mar 08, 2012 1:46 pm

Checking the connexion with Ping functionality

Post by jponnoua »

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.

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Checking the connexion with Ping functionality

Post by jarl »

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.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

jponnoua
Posts: 7
Joined: Thu Mar 08, 2012 1:46 pm

Re: Checking the connexion with Ping functionality

Post by jponnoua »

Thanks !

Julien.

jponnoua
Posts: 7
Joined: Thu Mar 08, 2012 1:46 pm

Re: Checking the connexion with Ping functionality

Post by jponnoua »

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:

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");
}
Julien.

jponnoua
Posts: 7
Joined: Thu Mar 08, 2012 1:46 pm

Re: Checking the connexion with Ping functionality

Post by jponnoua »

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.

Post Reply