C # network communication framework networkcomms kernel parsing one message transmission,

Source: Internet
Author: User

C # network communication framework networkcomms kernel parsing one message transmission,

Networkcomms.net from the UK official website of the network communication framework www.networkcomms.net Chinese website www.networkcomms.cn

In a network communication program, a local class or object needs to be transmitted to the other end of the communication. It is in the form of a binary stream during transmission over the network.

The object must be serialized as a binary stream when a message is sent.

The recipient will restore the binary data stream to an object.

We know that there is a message boundary problem when using the Tcp protocol to transmit messages. There are many methods to solve this problem, such:

(1) fixed-size messages

(2) Use Message Size Information

(3) Use message tag

Let's take a look at how the networkComms communication framework solves the message boundary problem, and use a picture to explain:

 

 

When the NetworkComms framework serializes a Packet object to binary data

For example, the length of the PacketHeader is stored in the first byte. the receiving end parses the packet header based on the length of the packet header stored in the first byte, and then according to the length of the Data part contained in the packet header, parse the data section.

When serializing binary data streams, you need to use a serializer. networkcomms uses the protobuf.net serializer that is popular on the Internet by default. Of course, you can also use the. net built-in

BinaryFormatter for serialization, or other serializer, as long as you specify the serializer during serialization.

Related Article

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.