我想实现一个服务器,它有一些方法,可以从中接受二维点数组(结构)。我想知道我是否应该将它实现为 WebService 或简单的 TCP 套接字。
目标系统是在 Debian Linux 上运行的 C++。就我的理解而言,WebService 是基于 XML/SOAP 的,我可以在任何其他客户端系统上使用该接口(interface),包括它的所有数据类型。相反,普通的 TCP 套接字只是读取字节数组。但是有没有一种简单的方法可以通过 TCP 套接字实现强类型数据传输,这样我就不需要网络服务器来运行 WebService?
这里是一个 C# 示例,服务器的界面应该是这样的:
public interface IService
{
void CloseShutter();
bool WriteFrame(Point[] frame, bool repeat);
MaintenanceInfo GetMaintenanceInfo();
}
public struct Point
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public int Color { get; set; }
public bool Draw { get; set; }
}
public struct MaintenanceInfo
{
public uint Lifetime { get; set; }
public bool UsedHours { get; set; }
}
感谢您的任何建议。
马蒂亚斯
最佳答案
您可以将 XML-RPC 用于 C++:http://xmlrpc-c.sourceforge.net/
关于c++ - 最佳实践 : Sending typed data over TCP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16360463/