Brief introduction
Google Protocolbuffer,Google offers implementations in three languages:java,C + + , and python , each implementation contains a language-specific compiler and library files. Because it is a binary format, it is much faster than using XML for data exchange.
It can be used to Distributed Applications data exchange between a heterogeneous environment. As a good efficiency and compatibility of the binary data transmission format, can be used for such as network transport, configuration files, data storage and many other areas.
The following is a description of C # using 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"; How to add a reference file
Message Loginreq
{
Required Int32 Result = 1;//0: Failure, 1: Success
Optional bytes cause = 2;
Optional bytes guid = 4;//Unique identity request, optional
}
Required Required Fields
Optional options available
Repeated list item
Protocol Generation
Put Protoc.exe, ProtoGen.exe, Google.ProtocolBuffers.dll files and bat files, proto files in the same folder in the download file
Generate protocol BAT file format:
@echo on
Protoc--descriptor_set_out=loginreq.protobin--include_imports Loginreq.proto
Protogen Loginreq.protobin
The LoginReq.cs is generated in this file
Time is here for the moment, and next time you edit it.
C # using the Google Protocolbuffer protocol