使用 C++ 的协议缓冲区客户端和 C# 后端?
如何通过 HTTP 或等效的 Web 服务将 C# 后端与 C++ 前端连接起来?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何通过 HTTP 或等效的 Web 服务将 C# 后端与 C++ 前端连接起来?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
这里分为三个部分;服务器(听起来像 C#)、客户端(听起来像 C++)和传输。将它们分开,并从最重要的开始:
传输:这里的重大决定是您希望数据采用什么形状。您提到了协议缓冲区,所以我们正在谈论二进制 - 但这可能是:
任何都应该有效;选择哪个取决于可用的工具。重要的是:通过网络获取一大块二进制文件。
此时您还需要考虑数据定义; .proto 文件 可以定义您的架构以及大多数协议缓冲区实现包括一个生成匹配类的工具。
IHttpHandler
) 或一个 Web 服务类。不管怎样,他们的工作实际上是运行一些逻辑并返回字节流。如何获取数据取决于您,最终的工作是填充 DTO 类型(在许多情况下从 .proto 生成,但并非严格必需)并通过序列化 API 运行它,将结果写入
列出了各种 protobuf 实现(C++、C# 等)此处。
There are three parts here; the server (sounds like C#), the client (sounds like C++) and the transport. Taking them separately, and starting with the most important:
the transport: big decision here is what shape you want the data to be in. You mention protocol buffers, so we're talking binary - but that could be:
Any should work; which to choose depends on the tools available. The important thing is : get a chunk of binary over the wire.
You also need to think about the data definition at this point; a .proto file can define your schema, and most protocol buffers implementations include a tool to generate matching classes.
IHttpHandler
) or a web-service class. Either way, their job is really to run some logic and return a byte stream. How you get your data is up to you, then ultimately the job is topopulate the DTO types (generated from .proto in many cases, but not strictly necessary) and run it through the serialization API, writing the result to the stream
The various protobuf implementations (C++, C#, etc) are listed here.
C++ 通过您选择的形式(Web 服务和其他)的 HTTP 请求访问后端的公开部分。
The C++ accesses the exposed parts of the back-end via HTTP-Requests in which form you choose (webservice and others).