Message format: fixed-length message]

Source: Internet
Author: User
Description of fixed-length packets

Fixed-length packets are the most widely used and simple message formats. It is easy to understand, but fixed-length packets also have their own limitations. The biggest problem is that if the length of the definition field needs to be extended, the related configuration and program code must be changed accordingly, so maintenance is inconvenient.
A fixed length message represents an information with a fixed length. The format of this document is common in the financial banking industry. Therefore, the bank account opening scenario is used as an example. For example, when opening an account on the bank console, you must record the name of the account owner. Assume that the user name is represented in 30 bytes, in this way, we can meet the needs of Chinese people, with 15 Chinese characters in length. Of course, we also need to open an account here, so we assume that the length is 8 bits in the format of "yyyymmdd ". In this way, we can use 30 + 8 (38) packets to record the data. But that's the problem. If we change the time format "YYYY-MM-DD" later, we will not only adjust the length of the fixed length, but also change the program to generate the specified time format. The example contains two domains. If a fixed-length packet contains multiple domains and there are many domain formats modified later, this situation highlights the limitations of the fixed-length packet.
[For more information, see http://blog.csdn.net/mahoking]

Fixed-Length Packets
Simple fixed-length message

The following is a simple message example. In this example, some basic information is selected.

 

Based on the information in the preceding table, we have assembled the packets as follows:
"77778710001 hitting the tiger 12345678912345678920141022"
When this message is sent to the background program, the background program parses the received packets according to the standards defined in the preceding table and then processes them.

 

Fixed-length message with variable-length domain

 

Assume that at 20140811, the transaction amount is 789.80 and 20141012, and the transaction amount is 1489.80. The following message is obtained:
77778710001 02014081178980 20141012148980"
In this way, you can output repeated fields cyclically by changing the long domain, so that the server can display the obtained information cyclically.

Sample program


This part is to be determined.

 

 

 

[For more information, see http://blog.csdn.net/mahoking]

 

Message format: fixed-length message]

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.