c # one kernel parses the network communication message frame networkcomms 2

networkcomms.net network communications framework official website from the UK www.networkcomms.net Chinese website www.networkcomms.cn

Network communication program, the local class or an object, to be transmitted to the other end of communication, when transmitted over the network is in the form of binary stream.

So when sending messages should target sequence into a binary stream

The other receives a binary data stream to be reduced to an object.

We know that the use of Tcp protocol to transmit messages when news border issues, to solve this problem, there are many ways, such as:

(1) a fixed-size message

 (2) using the message information size

 (3) using the message marker

We look at how networkComms communications framework to solve the boundary issue a message with a picture to illustrate:

 

  

 

When the frame NetworkComms Packet object serialization binary data

Above, the first byte is stored PacketHeader length of the receiving end based on data packet header length stored in the first byte, the parsed packet header, and the packet length of the data contained in the header portion of the data, the data parsing section.

When the message sequence of binary data stream, need serializer, networkcomms popular online protobuf.net frame using default serialization. Of course, you can also use the built-in .net 

BinaryFormatter serialize, or other serializer, as long as you specify it in the sequence of the time serializer can

Guess you like

Origin www.cnblogs.com/Jeely/p/10972335.html