Problem connecting to 32 bit prcoess from 64 bit process

RCF support and general discussion.
Post Reply
Anadi
Posts: 2
Joined: Wed Jun 12, 2013 11:03 am

Problem connecting to 32 bit prcoess from 64 bit process

Post by Anadi »

Hi
We recently moved to RCF 2.0.
On connecting to a server running on 32 bit process from a 64 bit process, I am running into an exception:

Code: Select all

 [17: Unexpected peer disconnection.][0: No sub system.][0: ][What: ][Context: c:\build_tools\packages\rcf-2.0.0.2679\src\rcf\ConnectionOrientedClientTransport.cpp:277
The code I am using to connect is :

Code: Select all

 
client.reset( new  RcfClient<I_Service>( RCF::TcpEndpoint(127.0.0.1, nPort) ) ) ;
 
	const int	RPC_TIMEOUT		= nTimeout * 1000 ;
	const int	CONNECT_TIMEOUT	= nConnectTimeOut * 1000 ;

client->getClientStub().setRemoteCallTimeoutMs( 90);
client->getClientStub().setConnectTimeoutMs( 15 ) ;
client->getClientStub().getTransport().setMaxMessageLength(1024*1024) ; 
      
client->FunctionCall(Arg1, Arg2);
The exception comes when I make the function call : (FunctionCall) from client! The issue exists only when the server is running on a 32 bit process and the client is running on 64 bit process . If client also is 32 bit process, there is no issue.

What can be causing this issue ?

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

Re: Problem connecting to 32 bit prcoess from 64 bit process

Post by jarl »

The most likely cause of this, is serialization of types whose bitwise size depends on the compiler. For example, 32 bit Visual C++ defines std::size_t as a 32 bit integer, while 64 bit C++ defines it as a 64 bit integer. So if you serialize a std::size_t anywhere in the arguments of your remote call, that will cause an incompatibility.

The same goes for "long" with gcc.

You can use the typedefs in boost/cstdint.hpp to get around this:

boost::int16_t
boost::int32_t
boost::int64_t
etc
Kind Regards

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

Anadi
Posts: 2
Joined: Wed Jun 12, 2013 11:03 am

Re: Problem connecting to 32 bit prcoess from 64 bit process

Post by Anadi »

I was using RCF_BOOST_SERIALIZATION macro. On removing that the problem went away.

Actually, I can recreate the problem when compiling the RCF demo code with RCF_BOOST_SERIALIZATION macro and running a 64 bit client and a 32 bit server in an x64 box. We are using boost 1.53

Thanks for your help!

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

Re: Problem connecting to 32 bit prcoess from 64 bit process

Post by jarl »

OK, I see what the problem is. Boost.Serialization binary archives are not compatible across different platforms. For example:

http://stackoverflow.com/questions/3708 ... -platforms

You'll either need to use Boost.Serialization text archives:

Code: Select all

client.getClientStub().setSerializationProtocol(RCF::Sp_BsText);
, (although it is likely to be slower), or you can use regular RCF binary serialization, which is fast and compatible across different platforms.
Kind Regards

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

Post Reply