简体   繁体   中英

protocol buffers with C++ client and C# back-end?

如何通过HTTP或等效的Web服务将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:

    • a raw octet-stream (think: downloading an image from a web-server)
    • a SOAP web-service returning a stream or byte[]
    • the same SOAP web-service returning MTOM

    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.

  • the server: depending on the choice above, this is either going to be a handler ( 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 to populate 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 client: same in reverse; generate your DTOs from the .proto, and run it through the deserialization API

The various protobuf implementations (C++, C#, etc) are listed here .

C ++通过HTTP-Requests(您选择的形式)(网络服务和其他)访问后端的公开部分。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM