CN101686176A - Method and device for transmitting and receiving message - Google Patents

Method and device for transmitting and receiving message Download PDF

Info

Publication number
CN101686176A
CN101686176A CN200810161819A CN200810161819A CN101686176A CN 101686176 A CN101686176 A CN 101686176A CN 200810161819 A CN200810161819 A CN 200810161819A CN 200810161819 A CN200810161819 A CN 200810161819A CN 101686176 A CN101686176 A CN 101686176A
Authority
CN
China
Prior art keywords
message
bag
module
message bag
boundary recognition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN200810161819A
Other languages
Chinese (zh)
Inventor
高峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Group Liaoning Co Ltd
Original Assignee
China Mobile Group Liaoning Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Group Liaoning Co Ltd filed Critical China Mobile Group Liaoning Co Ltd
Priority to CN200810161819A priority Critical patent/CN101686176A/en
Publication of CN101686176A publication Critical patent/CN101686176A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method and a device for transmitting and receiving a message. The method for transmitting the message comprises a step of setting a boundary recognition mark in each messagepacket. The method for receiving the message comprises the steps of: receiving the message packet; judging whether each message packet carries the boundary recognition mark; forming a complete messageof each packet according to the judgment result; and carrying out format conversion and forwarding the complete message to a user interface through PostMessage. The device for transmitting the message comprises a boundary recognition addition module for adding the boundary recognition mark in each message packet. The receiving device comprises a communication module and a user interface module, wherein the communication module is used for receiving the message packet, judging whether each message packet carries the boundary recognition mark, and forwarding the complete message carrying the boundary recognition mark to the user interface module through the PostMessage; and the user interface module is used for receiving the complete message packet from the communication module. The invention realizes the completeness of data message receiving, avoides occurrence of packet pasting, is independent of the processing and the analysis of the message and improves the usability of the system.

Description

Method and device that a kind of message sends, receives
Technical field
The present invention relates to moving communicating field, method and device that particularly a kind of message sends and receives.
Background technology
The sticking bag of TCP is meant that some bag data messages that transmit leg sends stick into a bag when the recipient receives, from receiving buffering area, the tail of the and then last bag data of head of back one bag data message.The reason that sticking bag phenomenon occurs is many-sided, and it both may be caused by transmit leg, also may be caused by the recipient.The sticking bag that transmit leg causes is caused by Transmission Control Protocol itself, and TCP is for improving efficiency of transmission, and transmit leg just sends bag data after often will collecting abundant data message.If the message that sends several times all seldom continuously, TCP once sends after can synthesizing a bag to these data messages according to optimized Algorithm usually, and the recipient has just received sticking bag data like this.The sticking bag that the recipient causes is owing to the untimely reception data of recipient's consumer process, thereby causes sticking bag phenomenon.This is to receive buffering area because the recipient is placed on system to the data of receiving earlier, consumer process fetches data from this buffering area, if last bag data message was not taken away by consumer process as yet when next bag data arrived, just be connected after the last bag data when then next bag data message system that is put into receives buffering area, and consumer process fetches data from system's reception buffering area according to predefined buffer size, has so just once got many bags data message (as shown in Figure 1).Sticking bag situation has two kinds, supposes that it is m byte that the user receives buffer length, and a kind of is that coherent bag all is complete packet (as shown in Figure 1 and Figure 2); Another kind of situation is the coherent incomplete bag (as shown in Figure 3) that is surrounded by.
Not every sticking bag phenomenon all needs to handle, if the data message of transmission is the Continuous Flow data (as file transfer) of not band structure, then needn't separate (abbreviation subpackage) to the bag of adhesion.But in practical engineering application, the data message of transmission is generally the data of band structure, at this moment just need do subpackage and handle.
Common solution is to adopt the packet of fixed length at present, perhaps increases a data packet length field and distinguish each packet in each packet, distinguishes each packet by the length that receives.Therefore, prior art must adopt packet fixed length or that increase length field in the processing of packet, and is dumb and efficient is lower.In addition, prior art is carried out synchronously for the processing of message, in case when data volume is bigger like this, can influence the response at interface.
Summary of the invention
The objective of the invention is at above prior art sending and receiving the problem that occurs sticking bag in the message process, by means such as Boundary Recognition, realize receiving data packets integrality, avoid sticking bag phenomenon to take place.
The invention provides the sending method of message, may further comprise the steps: the Boundary Recognition sign is set in each message bag; Send the message bag to the recipient.
In the technique scheme, the Boundary Recognition sign comprises heading sign and message trailer sign.
In the technique scheme,, can also comprise: calculate all message bag total lengths that are ready for sending sending the message bag to the recipient; Sending the message bag to the recipient, can also comprise: judging whether the length that has sent the message bag equals all message bag total lengths; If all message bags are sent completely, otherwise continue to send described message bag.
The present invention also provides the method for reseptance of message, may further comprise the steps: receive the message bag; Judge whether each message bag carries the Boundary Recognition sign; Form the complete message of every bag according to judged result; Repeat above-mentioned steps, until receiving all message bags that sent.
In the above-mentioned technical scheme that relates to method of reseptance, after receiving all message bags that sent, can also comprise: form complete message, carry out format conversion and be forwarded to user interface by PostMessage.
In the above-mentioned technical scheme that relates to method of reseptance, judge whether each message bag carries the Boundary Recognition sign, and be specially: judge whether the message bag that sends has the heading sign according to the complete message that judged result forms every bag; If preserve the message that receives, otherwise dropping packets and continuation receive; Judge whether the message bag that sends has the message trailer sign; If form complete message bag, otherwise continue to receive the content of message bag.
In the above-mentioned technical scheme that relates to method of reseptance, receive the message bag and can specifically adopt the mode of barrage reception to carry out.
In addition, the invention provides the dispensing device of message, comprising: boundary recognition addition module is used for increasing the Boundary Recognition sign at each message bag; The message sending module is used to send the message bag to the recipient.
In the above-mentioned technical scheme that relates to dispensing device, can also comprise: the message computing module is used to calculate all message bag total lengths that are ready for sending; The message length judge module is used for judging whether sent the message packet length equals all message bag total lengths.
In addition, the present invention also provides the receiving system of message, comprising: communication module, be used to receive the message bag, and judge whether each described message bag carries the Boundary Recognition sign; Subscriber interface module is used to receive all complete message packet from communication module.
In the above-mentioned technical scheme that relates to receiving system, can also comprise: forwarding module, the complete message that is used for will carrying by PostMessage the Boundary Recognition sign is transmitted to subscriber interface module.
In the above-mentioned technical scheme that relates to receiving system, communication module may further include: the message receiver module is used to receive the message bag; The Boundary Recognition judge module is used to judge whether each message bag carries the Boundary Recognition sign.
In the above-mentioned technical scheme that relates to receiving system, the Boundary Recognition judge module may further include: heading recognin module is used to judge whether the message bag of transmission has the heading sign; Sub module stored is used for when heading recognin module judges that the message bag that sends has heading the message that storage receives; The packet loss submodule is used for when heading recognin module judges that the message bag that sends does not have heading dropping packets; Message trailer recognin module is used to judge whether the message bag of transmission has the message trailer sign.
Compared with prior art, the present invention has the following advantages:
Message sending, receiving method of the present invention and device adopt integrality Boundary Recognition sign and barrage reception pattern are set both can have realized receiving data packets, avoid sticking bag phenomenon to take place; Adopt the asynchronous transmission means of PostMessage can make the processing of message conciliate phase separation mutually independently simultaneously, improve the ease for use of system.
Description of drawings
Fig. 1 is first kind of accepting state schematic diagram of message bag;
Fig. 2 is second kind of accepting state schematic diagram of message bag;
Fig. 3 is the third accepting state schematic diagram of message bag;
Fig. 4 is that message sends, receives schematic diagram;
Fig. 5 is file transmitting method flow chart of the present invention (embodiment 1);
Fig. 6 is a message method of reseptance flow chart of the present invention (embodiment 2);
Fig. 7 is packet transmission device schematic diagram of the present invention (embodiment 3);
Fig. 8 is a message receiving system schematic diagram of the present invention (embodiment 4).
Embodiment
Below in conjunction with accompanying drawing, the specific embodiment of the present invention is described in detail.
The present invention adopts means such as Boundary Recognition, barrage reception and asynchronous transmission to realize the transmission and the reception of message bag.Boundary Recognition is a kind of packetization technique efficiently, distinguish each complete message bag by special Boundary Recognition sign (for example heading and message trailer), and guarantee to receive a complete message in conjunction with the barrage reception technology at every turn, the message that receives is through handling, be converted into the understandable form of client (for example CMsgPack class form), send to the UI module of client again by PostMessage asynchronous transmission means.
Asynchronous transmission realizes by PostMessage, corresponding with PostMessage is SendMessage, the difference of the two is: SendMessage is when a window sends message, can not put into message queue to message, but directly send to window.Window is just handled after receiving message at once, and the result is returned in the back of finishing dealing with; And PostMessage is when window sends message, and message is put into message queue, just return, as for message have do not have processed and when processed it be ignorant.For example, if notice UI will copy a file, words with SendMessage, can wait until that UI finishes document copying and just can return, if and use PostMessage, message is issued the back and has just returned immediately, can not finish by the pending file copy, can continue the processing of back like this after the PostMessage.Therefore, PostMessage only puts into formation to message, no matter whether other programs are handled all and returned, continues execution then, and this is that an asynchronous message is thrown in function, and therefore the response for the UI module does not influence.If do not adopt asynchronous transmission mechanism, when handling a large amount of message, interface response will postpone because of the processing of message, has reduced the ease for use of client-side program.
The barrage reception pattern is a kind of of Socket receiving mode, is the default mode of Socket, and promptly the function obstruction finishes up to calling.May cause the function of obstruction to have: connect (), accept (), read, select (), poll (), gethostbyname () etc.Blocking with process transfer recvfrom function is that example describes the obstruction process, when process transfer recvfrom function, if system kernel does not have data ready, system will wait for data ready, after ready, copy, copy finishes the normal return data in back, thereby the data in the packet are handled.
Message transmitting party of the present invention can be engaged in leading to server for car, and the recipient can be the communication module of car affair client terminal, and UI is meant the interface processing module (as shown in Figure 4) of car affair client terminal.
(embodiment 1) as shown in Figure 5, in the embodiment of the invention 1, it is as follows that message sends handling process:
Step S102 calculates all the message bag total lengths be ready for sending (can obtain the message bag total length that will send by strlen () function);
Step S104 is that each message bag increases Boundary Recognition sign, be specially heading and message trailer sign (heading is<operation_out 〉; Message trailer is</operation_out 〉);
Step S106 sends message.Form is as follows:<operation_out〉message content</operation_out 〉;
Step S108 judges whether sent the message bag equals message bag total length, if equal then be sent completely; If less than continue would to send.(message total length herein is the cumulative length of all message bags)
(embodiment 2) as shown in Figure 6, the reception handling process of message is as follows:
Step S202 receives the message bag.If message is greater than buffer size, then increase buffering area and be 2 times of message size, when the size of message will surpass buffering area, buffering area can be expanded as 2 times of message size automatically like this, both can avoid buffering area to overflow, high more a lot of more at every turn than the efficient of redistributing the space again simultaneously;
Step S204 judges whether every packet voice has heading sign (<operation_out 〉), if do not have, then abandons this message, and returns step S202 and continue to receive; If have, change step S206;
Step S206 preserves the message that receives;
Step S208 judges whether this packet voice has message trailer sign (</operation_out 〉), if do not have, changes step S202 and continues to receive; If have, change step S210 (at this moment can determine to have formed a complete message bag);
Step S210 repeats above-mentioned steps, until receiving all complete message bags that sent;
Step S212 forms complete message, carries out format conversion and is forwarded to user interface according to message ID by PostMessage.
For ease of understanding, now message bag accepting state is carried out simple declaration in conjunction with Fig. 1 to Fig. 3.As shown in Figure 1, when a plurality of message bag of the disposable reception of client,, can distinguish each message bag, and handle respectively by increasing the Boundary Recognition sign; As shown in Figure 2, when the many mistakes of the total length scale of message bag buffering area, because the message of front has taken buffering area just, therefore only need each message bag of sequential processes to get final product, disposing in the buffering area can be carried out the processing of back automatically; As shown in Figure 3, when the many mistakes of the total length scale of message bag buffering area, and the message of front can not take buffering area just, therefore need to give again buffering area allocation space (described in the step S202 among the front embodiment 2), holding a complete message bag, and then each complete message bag is handled respectively.
Be illustrated in figure 7 as packet transmission device schematic diagram (embodiment 3), packet transmission device 1 (being engaged in leading to server with car is example) specifically comprises message computing module 2, is used to calculate all message bag total lengths that are ready for sending; Boundary recognition addition module 3 is used for increasing the Boundary Recognition sign at each message bag; Message sending module 4 is used to send the message bag to the recipient; Message length judge module 5 is used for judging whether sent the message bag equals message bag total length.Can carry out mutual between the above-mentioned module.
Be illustrated in figure 8 as message receiving system schematic diagram (embodiment 4), message receiving system 6 (is example with car affair client terminal), specifically comprise communication module 7, be used to receive the message bag, judge whether each message bag carries Boundary Recognition sign, and be transmitted to subscriber interface module by the complete message packet that PostMessage will carry the Boundary Recognition sign; Subscriber interface module 8 is used to receive the complete message packet from communication module 7.
Communication module 7 comprises message receiver module 10 again, is used to receive the message bag; Boundary Recognition judge module 9 is used to judge whether each described message bag carries the Boundary Recognition sign; Forwarding module 11, the complete message packet that is used for will carrying by PostMessage Boundary Recognition sign is forwarded to subscriber interface module.
Wherein, Boundary Recognition judge module 9 further comprises: heading recognin module 12 is used to judge whether the message bag of transmission has the heading sign; Sub module stored is used for when heading recognin module judges that the message bag that sends has heading the message that storage receives; Packet loss submodule 14 is used for abandoning described message when heading recognin module judges that the described message bag that sends does not have heading; Message trailer recognin module 15 is used to judge whether the message bag of transmission has the message trailer sign.If judge existing heading, message trailer is arranged again, will form a complete message bag.
Message sending, receiving method of the present invention and device, by means such as Boundary Recognition, barrage reception and asynchronous transmission, both can realize receiving data packets integrality, avoid sticking bag phenomenon to take place, it is independent mutually to make the processing of message conciliate phase separation simultaneously, improves the ease for use of system.
More than disclosed only be several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.

Claims (13)

1, a kind of sending method of message is characterized in that, may further comprise the steps:
The Boundary Recognition sign is set in each message bag;
Send described message bag to the recipient.
2, method according to claim 1 is characterized in that, described Boundary Recognition sign comprises heading sign and message trailer sign.
3, method according to claim 1 and 2 is characterized in that,
, also comprise to the recipient at described transmission message bag: calculate all message bag total lengths that are ready for sending;
, to the recipient, also comprise at described transmission message bag: judge whether the length that has sent the message bag equals described all message bag total lengths;
If described all message bags are sent completely,
Otherwise continue to send described message bag.
4. the method for reseptance of a message is characterized in that, may further comprise the steps:
Receive the message bag;
Judge whether each message bag carries the Boundary Recognition sign;
Form the complete message of every bag according to judged result;
Repeat above-mentioned steps, until receiving all message bags that sent.
5, method according to claim 4 is characterized in that, and is described after receiving all message bags that sent, also comprises: form complete message, carry out format conversion and be forwarded to user interface by PostMessage.
6. according to claim 4 or 5 described methods, it is characterized in that describedly judge whether each message bag carries Boundary Recognition sign, and be specially according to the complete message that judged result forms every bag:
Judge whether the described message bag that sends has the heading sign;
If, preserve the message that receives,
Receive otherwise abandon described message and continue;
Judge whether the described message bag that sends has the message trailer sign;
If, form complete described message bag,
Otherwise continue to receive the content of described message bag.
According to claim 4 or 5 described methods, it is characterized in that 7, described reception message bag specifically adopts the mode of barrage reception to carry out.
8, a kind of dispensing device of message is characterized in that, comprising:
Boundary recognition addition module is used for increasing the Boundary Recognition sign at each message bag;
The message sending module is used to send described message bag to the recipient.
9, device according to claim 8 is characterized in that, also comprises:
The message computing module is used to calculate all message bag total lengths that are ready for sending;
The message length judge module is used for judging whether sent the message packet length equals described all message bag total lengths.
10, a kind of receiving system of message is characterized in that, comprising:
Communication module is used to receive the message bag, judges whether each described message bag carries the Boundary Recognition sign;
Subscriber interface module is used to receive all complete message packet from communication module.
11, device according to claim 10 is characterized in that, also comprises: forwarding module, the complete message that is used for will carrying by PostMessage Boundary Recognition sign is transmitted to subscriber interface module.
12, according to claim 10 or 11 described devices, it is characterized in that described communication module further comprises:
The message receiver module is used to receive the message bag;
The Boundary Recognition judge module is used to judge whether each described message bag carries the Boundary Recognition sign.
13, device according to claim 12 is characterized in that, described Boundary Recognition judge module further comprises:
Heading recognin module is used to judge whether the described message bag of transmission has the heading sign;
Sub module stored is used for when described heading recognin module judges that the described message bag that sends has heading the described message that storage receives;
The packet loss submodule is used for abandoning described message when described heading recognin module judges that the described message bag that sends does not have heading;
Message trailer recognin module is used to judge whether the described message bag of transmission has the message trailer sign.
CN200810161819A 2008-09-24 2008-09-24 Method and device for transmitting and receiving message Pending CN101686176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200810161819A CN101686176A (en) 2008-09-24 2008-09-24 Method and device for transmitting and receiving message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200810161819A CN101686176A (en) 2008-09-24 2008-09-24 Method and device for transmitting and receiving message

Publications (1)

Publication Number Publication Date
CN101686176A true CN101686176A (en) 2010-03-31

Family

ID=42049158

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200810161819A Pending CN101686176A (en) 2008-09-24 2008-09-24 Method and device for transmitting and receiving message

Country Status (1)

Country Link
CN (1) CN101686176A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438012A (en) * 2011-11-15 2012-05-02 航天科工深圳(集团)有限公司 Protocol communication method and system thereof
CN105991223A (en) * 2015-02-13 2016-10-05 Tcl集团股份有限公司 Method and system for preventing packet splicing in TCP network data transmission
CN107124736A (en) * 2017-05-27 2017-09-01 努比亚技术有限公司 Data transmission system and method
CN107148052A (en) * 2017-05-27 2017-09-08 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107222429A (en) * 2017-05-27 2017-09-29 努比亚技术有限公司 Data transmission system and method
CN107241436A (en) * 2017-07-18 2017-10-10 山东亚华电子股份有限公司 A kind of method of the transmission of TCP network high-speeds packet splicing and storage
CN107257566A (en) * 2017-05-27 2017-10-17 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107257567A (en) * 2017-05-27 2017-10-17 努比亚技术有限公司 Data transmission system and method
CN107277797A (en) * 2017-05-27 2017-10-20 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107277796A (en) * 2017-05-27 2017-10-20 努比亚技术有限公司 Mobile terminal and its data transmission method
CN109257355A (en) * 2018-09-26 2019-01-22 郑州云海信息技术有限公司 One kind being based on Transmission Control Protocol data transmission method, system and associated component
CN109510781A (en) * 2018-11-22 2019-03-22 成都傅立叶电子科技有限公司 A kind of diversiform data distribution control method and system
CN111148324A (en) * 2019-12-30 2020-05-12 众盒智能科技(上海)有限公司 Light control edge host

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438012A (en) * 2011-11-15 2012-05-02 航天科工深圳(集团)有限公司 Protocol communication method and system thereof
CN105991223A (en) * 2015-02-13 2016-10-05 Tcl集团股份有限公司 Method and system for preventing packet splicing in TCP network data transmission
CN107257566A (en) * 2017-05-27 2017-10-17 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107148052A (en) * 2017-05-27 2017-09-08 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107222429A (en) * 2017-05-27 2017-09-29 努比亚技术有限公司 Data transmission system and method
CN107124736A (en) * 2017-05-27 2017-09-01 努比亚技术有限公司 Data transmission system and method
CN107257567A (en) * 2017-05-27 2017-10-17 努比亚技术有限公司 Data transmission system and method
CN107277797A (en) * 2017-05-27 2017-10-20 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107277796A (en) * 2017-05-27 2017-10-20 努比亚技术有限公司 Mobile terminal and its data transmission method
CN107241436A (en) * 2017-07-18 2017-10-10 山东亚华电子股份有限公司 A kind of method of the transmission of TCP network high-speeds packet splicing and storage
CN109257355A (en) * 2018-09-26 2019-01-22 郑州云海信息技术有限公司 One kind being based on Transmission Control Protocol data transmission method, system and associated component
CN109510781A (en) * 2018-11-22 2019-03-22 成都傅立叶电子科技有限公司 A kind of diversiform data distribution control method and system
CN111148324A (en) * 2019-12-30 2020-05-12 众盒智能科技(上海)有限公司 Light control edge host

Similar Documents

Publication Publication Date Title
CN101686176A (en) Method and device for transmitting and receiving message
CN103746938A (en) Method and device for transmitting data packet
CN101047615B (en) Control method for Ethernet data flow
EP1591906A1 (en) Efficient data transfer from an ASIC to a host using DMA
CN102045772A (en) Data transmission method and device
CN101557348A (en) Message forwarding method and device based on token bucket
CN107872396A (en) Communication means, processing equipment, terminal device and server with overtime control
CN101873475A (en) Control command sending method, data transmission method, monitoring system and device
CN1992582B (en) Implementation method for adaptive variable slide receiving window of broadband signaling link
CN102811176A (en) Data traffic control method and device
CN101742701A (en) Device, method and system for treating AT command
KR20070026109A (en) System for transmitting and receiving data, transmitting apparatus, receiving apparatus, and method for transmitting and receiving data
CN102148743B (en) Data flow control method, device and mobile terminal
CN101610217B (en) Method for implementing message transmission between extensible processor and switch chip and system thereof
CN102487330B (en) Method and device for sending operation, administration and maintenance messages
CN101079815B (en) Message forwarding method, system and device
CN111064768B (en) Printer data transmission control method, device, equipment and storage medium
CN102088420A (en) Method and system for transmitting multi-media message as well as multi-media message service center (MMSC)
CN102299861A (en) Message traffic control method
CN101227688A (en) Method for transmitting data through USB interface on mobile phone
CN1901595B (en) Method for sending fax to radio fax device
CN100574430C (en) Multichannel real-time audio and video data transmission method for uplink and device based on embedded system
CN100505819C (en) Wireless fax mobile terminal compatible with real-time and caching scheme and fax receiving method
CN105207795A (en) IOT communication method and device
CN100464511C (en) Ether net communication system and method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Open date: 20100331