How to close(disconnect) client from the server side?

RCF support and general discussion.
Post Reply
cinsk
Posts: 5
Joined: Mon Mar 18, 2013 6:24 am

How to close(disconnect) client from the server side?

Post by cinsk »

My server application uses RCF client callbacks. (I believe that in this case,
there is 2 TCP connection provided that I use TCP transport.)

sometimes, when the client calls server-side method, the server need to
disconnect the client (if the server decided to).

Is there anyway to forcefully disconnect the client from the server-side?

Thanks.

cinsk
Posts: 5
Joined: Mon Mar 18, 2013 6:24 am

Re: How to close(disconnect) client from the server side?

Post by cinsk »

If I add more,

I want, when the server decided to, the server need to forcefully disconnect the client so that
2 TCP connection should be released.

Thanks.

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

Re: How to close(disconnect) client from the server side?

Post by jarl »

There is only ever a single TCP connection associated with a RcfClient<> object. If you have two TCP connections in play, I assume you have a RcfClient<> on the client side, for client-to-server calls, and a RcfClient<> on the server side, for server-to-client calls. The two connections are managed separately, and you can close either one without affecting the other.

If from the server side you want to close both, in response to a remote call from the client, then first off you should find the relevant server-side RcfClient<> object and close that, and then you can close the connection the remote call came in on, by calling:

RCF::getCurrentSession().setCloseSessionAfterWrite(true);

, which will close the TCP connection after the response has been sent.

Alternatively you could send a response back to the client, instructing it to close the connection.
Kind Regards

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

Post Reply