如果传递了long类型,则32位客户端如何与64位服务器通信? [英] How can a 32 bit client communicate with a 64 bit server if long type is passed?

查看:203
本文介绍了如果传递了long类型,则32位客户端如何与64位服务器通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在32位Windows 7上运行的32位C ++ GUI应用程序。我们计划将带有C ++应用程序的服务器迁移到64位linux。我们注意到长类型在64位中更大。这将与从64位传递到32位的客户端服务器消息不兼容。解决这种不兼容的好方法是什么?我们需要更改代码吗?怎么样?还是我们使用第三方软件进行转换?是什么软件?

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?

推荐答案

这就是为什么存在标准化的 int32_t uint32_t 类型等。,因此您可以根据自己的需要专门选择类型。

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

替换所有 long 都键入 int32_t ,特别是如果它是一个大项目,但是您(希望)只需要执行一次。解决此问题的另一种方法是将数据序列化为文本格式,然后在接收端将其反序列化,这具有很大的优势,它将使通信几乎完全独立于平台。

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.

这篇关于如果传递了long类型,则32位客户端如何与64位服务器通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆