c++ - 最佳实践 : Sending typed data over TCP

标签 c++ web-services sockets soap tcp

我想实现一个服务器,它有一些方法,可以从中接受二维点数组(结构)。我想知道我是否应该将它实现为 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/

相关文章:

c - 套接字 - 在客户端使用 INADDR_ANY

sockets - 我尝试使用 s_client (openssl) 和 javax.net.ssl 包连接到加密套接字

c++ - __declspec(dllimport) 导致编译器在 MSVC 2010 上崩溃

web-services - 为我正在构建的新网站创建 API 时应该考虑哪些要点?

PHP Nusoap session

javascript - 在 javascript Ajax 调用中从 Web 服务中的 XMLDocument 获取响应...?

c# - 使用 recieveFrom 获取多播数据包的源 IP

c++ - 错误 : no matching member function for call to 'reset' (shared pointers)

c++ - 初始化器但类型不完整?

c# - 舍入浮点值