C # using the Google Protocolbuffer protocol

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.