How can a 32 bit client communicate with a 64 bit server if long type is passed?

夙愿已清 提交于 2019-12-25 05:35:30

问题


We have a 32-bit C++ GUI application running on 32 bit windows 7. We are planning to migrate our server with C++ apps to 64-bit linux. We have noticed that long types are larger in 64 bit. This will be incompatible with the client-server message passing from 64-bit to 32-bit. What is a good way to solve this incompatibility? Do we need to change the code? How? or Do we use a third party software to do the conversion? What software is it?


回答1:


That's why there is the standardized int32_t and uint32_t types etc., so you could specifically select type depending on your needs.

It might be quite a lot of work to replace all long types to int32_t in all structures you send, especially if it's a big project, but you (hopefully) only have to do it once. Another way of solving this problem is to serialize the data into a text-format and then deserialize it on the receiving side, this has the big advantage that it will make the communication almost completely platform independent.



来源:https://stackoverflow.com/questions/20394060/how-can-a-32-bit-client-communicate-with-a-64-bit-server-if-long-type-is-passed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!