关于C# 用Google Protocol Buffers 压缩数据传输到服务器 服务器用C++ 调用Google Protocol Buffers 解包
我们现在遇到的问题是 C# 用Google的缓存协议打包 自己解是可以解出来的 但是到了服务器端 C++调用Google缓存协议
解包就出现问题 解出来的数据不对
我们现在遇到的问题是 C# 用Google的缓存协议打包 自己解是可以解出来的 但是到了服务器端 C++调用Google缓存协议
解包就出现问题 解出来的数据不对
解决方案 »
- object类型 转成二进制类型
- 写硬盘防拷贝的具体思路
- C#导出Excel 为Excel动态设置列名???
- TcpListener多线程异步接收TcpClient数据,线程数量快速上升问题。
- asp.net 访问用 .net 写的 windows service 怎么实现,安全方面要注意什么?
- 读取数据超慢,求教解决之道,高手请进
- 如何实现DatGrid从表的添加、修改操作
- 100分求c#.net下水晶报表与数据集连接代码(分不够另开贴加)
- C#窗体如何判断在非本窗体按下ctrl+c并获取全中的值
- C#调用Oralce存储过程报错。
- winform时间控件的问题。
- C#客户端程序在Word插入页码,并设置页码格式
required string name = 1;
required int32 id = 2;
optional string email = 3;enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
} message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}repeated PhoneNumber phone = 4;
} 而Protocol Buffers的作用,就是将以上格式的数据类型,自动生成Java, Python, and C++的代码,然后以下一系列代码就可以直接调用了:(C++中)Person person;
person.set_name("John Doe");
person.set_id(1234);
person.set_email("[email protected]");
fstream output("myfile", ios::out | ios::binary);
person.SerializeToOstream(&output); fstream input("myfile", ios::in | ios::binary);
Person person;
person.ParseFromIstream(&input);
cout << "Name: " << person.name() << endl;
cout << "E-mail: " << person.email() << endl;
/// <summary>
/// 打包预警参数为byte字节流数组
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public static byte[] SerializeConnditionMonitor(Collection<ConnditionMonitor> list)
{
byte[] readBuffer = new byte[BufferLength];
using (MemoryStream ms = new MemoryStream())
{
Serializer.Serialize<Collection<ConnditionMonitor>>(ms, list);
readBuffer = ms.ToArray(); }
return readBuffer;
}这个是我的C#客户端 采用google缓存协议 打包的数据 打包完后将这个byte[] 数组发到服务器的
但是到了服务器 C++用google缓存协议在解的时候就出现错误 我现在怀疑的是 是不是google缓存协议不支持 一端用C#打包 一端用C++解包
请高人指教。