C # Use the google protocolbuffer protocol,
Introduction
Google protocolbuffer, google provides three languages: java, c ++, and python, each of which contains the compiler and library files of the corresponding language. Because it is a binary format, it is much faster than using xml for data exchange.
It can be used for data communication between distributed applications or data exchange in heterogeneous environments. As a binary data transmission format with excellent efficiency and compatibility, it can be used in many fields such as network transmission, configuration file, and data storage.
The following describes how C # uses protocolbuffer.
Download protobuf-csharp-port-2.4.1.521-release-binaries.zip
Http://code.google.com/p/protobuf-csharp-port/
Proto File
// Import "Base. proto"; add reference file Method
Message LoginReq
{
Required int32 Result = 1; // 0: failed, 1: Successful
Optional bytes Cause = 2;
Optional bytes guid = 4; // unique ID request, optional
}
Required
Optional Option
Repeated list item
ProtocolGenerate
Put protoc.exe‑protogen.exe and Google. ProtocolBuffers. dll files in the downloaded file into the same folder as bat files and proto files.
Generate protocol bat file format:
@ Echo on
Protoc -- descriptor_set_out = LoginReq. protobin -- include_imports LoginReq. proto
Protogen LoginReq. protobin
LoginReq. cs is generated in this file.
The time is urgent and will be edited later.