CN107689996B - Data transmission method and device and terminal equipment - Google Patents

Data transmission method and device and terminal equipment Download PDF

Info

Publication number
CN107689996B
CN107689996B CN201710789054.4A CN201710789054A CN107689996B CN 107689996 B CN107689996 B CN 107689996B CN 201710789054 A CN201710789054 A CN 201710789054A CN 107689996 B CN107689996 B CN 107689996B
Authority
CN
China
Prior art keywords
storage area
data
transmission object
writing
address field
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.)
Active
Application number
CN201710789054.4A
Other languages
Chinese (zh)
Other versions
CN107689996A (en
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.)
Beijing Yiling Technology Co ltd
Original Assignee
Wuhan Douyu Network Technology 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201710789054.4A priority Critical patent/CN107689996B/en
Publication of CN107689996A publication Critical patent/CN107689996A/en
Application granted granted Critical
Publication of CN107689996B publication Critical patent/CN107689996B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Telephone Function (AREA)

Abstract

The invention relates to the technical field of communication, and provides a data transmission method, a device and terminal equipment.

Description

Data transmission method and device and terminal equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data transmission method, an apparatus, and a terminal device.
Background
With the development of computer and internet technologies, various intelligent terminals such as computers and mobile phones have become important components in people's work and life, and the performance of the intelligent terminals is increasingly enhanced, so that users can complete work, browse web pages, play audio/video, acquire stock information in real time and the like by using the intelligent terminals. However, compared with the increasingly enhanced performance of the intelligent terminal, the performance of the communication network is not significantly improved, especially when a plurality of intelligent terminals simultaneously depend on the same network for data transmission, the network transmission speed is very slow, and in addition, the network communication transmission protocol depending on the communication between the intelligent terminal and the network device is not optimized enough at present, so that the network transmission speed is affected.
Disclosure of Invention
The present invention provides a data transmission method, a data transmission device and a terminal device, so as to improve the above problem.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, the present invention provides a data transmission method, applied to a terminal device, where the method includes: acquiring a first transmission object to be transmitted; writing the data of the first transmission object into a second transmission object, wherein the memory size of the second transmission object is consistent with the data size of the first transmission object; and sending the data of the second transmission object to other terminal equipment.
In a second aspect, the present invention further provides a data transmission device, which is applied to a terminal device, and the device includes an obtaining module, a data writing module, and a data sending module. The acquisition module is used for acquiring a first transmission object to be transmitted; the data writing module is used for writing the data of the first transmission object into a second transmission object, wherein the memory size of the second transmission object is consistent with the data size of the first transmission object; and the data sending module is used for sending the data of the second transmission object to other terminal equipment.
In a third aspect, the present invention further provides a terminal device, where the terminal device includes a memory, a processor, and a data transmission apparatus, where the data transmission apparatus is stored in the memory and includes one or more software function modules executed by the processor. The data transmission device comprises an acquisition module, a data writing module and a data sending module. The acquisition module is used for acquiring a first transmission object to be transmitted; the data writing module is used for writing the data of the first transmission object into a second transmission object, wherein the memory size of the second transmission object is consistent with the data size of the first transmission object; and the data sending module is used for sending the data of the second transmission object to other terminal equipment.
Compared with the prior art, the invention has the following beneficial effects: according to the data transmission method, the data transmission device and the terminal equipment, the data of the first transmission object to be transmitted are written into the second transmission object, so that the size of the memory of the second transmission object is consistent with the size of the data of the first transmission object, and then the data of the second transmission object are sent to other terminal equipment, so that the memory occupied by the data of the transmission object is reduced, the network communication transmission speed is improved, and the data transmission method, the device and the terminal equipment have good practicability.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 shows a block diagram of a terminal device according to an embodiment of the present invention.
Fig. 2 shows a flowchart of a data transmission method according to an embodiment of the present invention.
Fig. 3 is a flowchart illustrating sub-steps of step S102 shown in fig. 2.
Fig. 4 is a flowchart illustrating sub-steps of sub-step S1022 shown in fig. 3.
Fig. 5 is a flowchart of sub-steps of the sub-step S1023 shown in fig. 3.
Fig. 6 is a flowchart illustrating sub-steps of step S103 shown in fig. 2.
Fig. 7 is a block diagram of a data transmission apparatus according to an embodiment of the present invention.
Fig. 8 is a block diagram illustrating a data writing module in the data transmission apparatus shown in fig. 7.
Fig. 9 is a block diagram illustrating an address field writing unit in the data writing module shown in fig. 8.
Fig. 10 is a block diagram illustrating a name field writing unit in the data writing module shown in fig. 8.
Fig. 11 is a block diagram illustrating a data transmission module in the data transmission apparatus shown in fig. 7.
Icon: 100-a terminal device; 101-a memory; 102-a memory controller; 103-a processor; 200-a data transmission device; 201-an acquisition module; 202-a data write module; 2021-field acquisition unit; 2022-address field write unit; 20221-first byte count acquisition unit; 20222-first byte count write unit; 20223-a first execution unit; 20224-a second execution unit; 2023-name field write unit; 20231-a second byte count acquisition unit; 20232-second byte count write unit; 20233-a third execution unit; 20234-a fourth execution unit; 203-a data transmission module; 2031-a memory pointer acquisition unit; 2032-a memory size obtaining unit; 2033-a transmission object acquisition unit; 2034-a transmission unit.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Referring to fig. 1, fig. 1 is a block diagram illustrating a terminal device 100 according to an embodiment of the present invention. The terminal device 100 may be, but is not limited to, a smart phone, a Personal Computer (PC), a tablet PC, a Personal Digital Assistant (PDA), a Mobile Internet Device (MID), a web server, and the like. The terminal device 100 includes a data transmission apparatus 200, a memory 101, a memory controller 102, and a processor 103.
The memory 101, the memory controller 102 and the processor 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The data transmission device 200 includes at least one software functional module which can be stored in the memory 101 in the form of software or firmware (firmware) or is fixed in an Operating System (OS) of the terminal device 100. The processor 103 is used for executing executable modules stored in the memory 101, such as software functional modules or computer programs included in the data transmission device 200.
The Memory 101 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 101 is configured to store a program, and the processor 103 executes the program after receiving an execution instruction, and the method executed by the server defined by the process disclosed in any embodiment of the present invention may be applied to the processor 103, or implemented by the processor 103.
The processor 103 may be an integrated circuit chip having signal processing capabilities. The processor 103 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), a voice processor, a video processor, and the like; but may also be a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor 103 may be any conventional processor or the like.
First embodiment
Referring to fig. 2, fig. 2 is a flowchart illustrating a data transmission method according to an embodiment of the present invention. The data transmission method comprises the following steps:
step S101, a first transmission object to be transmitted is obtained.
In the embodiment of the present invention, the first transport object may be any one transport object in a network communication transport protocol, and the network communication transport protocol may be a data packet, where the data packet includes a plurality of transport objects. As an embodiment, the first transport object may include an address field and a name field, for example, the first transport object may be represented by the following code:
Figure BDA0001398730320000051
the Message is a first transmission object, id is an address field, and name is a name field, and as can be seen from the above codes, the Message occupies 400 bytes of memory in total, but the actual memory size of the address field id is 100 bytes, and the actual memory size of the name field name is 100 bytes, that is, the Message has 200 empty bytes.
Step S102, writing the data of the first transmission object into a second transmission object, where the memory size of the second transmission object is consistent with the data size of the first transmission object.
In the embodiment of the present invention, the second transmission object may be a transmission object that stores data of the first transmission object. The method for writing the data of the first transmission object into the second transmission object can be as follows: firstly, a second transmission object can be defined as a Pickle, and a memory of the Pickle is preset to be 4 KB; and then writing the address field and the name field of the first transmission object into a second transmission object, so that the memory size of the second transmission object is consistent with the data size of the first transmission object. In one embodiment, during the process of writing the data of the first transfer object into the second transfer object, the realloc function may be called to automatically increase the memory of the Pickle, and the size of the memory may always be consistent with the size of the data written into the Pickle by the Message.
Referring to fig. 3, step S102 may include the following sub-steps:
in the sub-step S1021, the address field and the name field of the first transmission object are obtained.
In the embodiment of the present invention, the address field and the name field of the first transmission object are obtained, and the actual memory sizes of the address field id and the name field name are obtained, that is, the obtained address field of the first transmission object is 100 bytes, and the obtained name field of the first transmission object is 100 bytes. As an implementation, a strlen function may be called to obtain the actual memory size of the address field id and the name field name.
In sub-step S1022, the address field is written into the second transport object.
In the embodiment of the present invention, after the address field is obtained, the address field may be written into a first storage area of the second transfer object, where the first storage area may include a first byte number storage area and an address field storage area, and addresses of the first byte number storage area and the address field storage area are consecutive. And writing the address field into the second transmission object, namely writing the byte number of the address field into the first byte number storage area, and writing all the bytes of the address field into the address field storage area.
As an embodiment, the method for writing the address field into the second transmission object may be: firstly, calling a strlen function to acquire the byte number of an address field, wherein the byte number can be 100; secondly, calling a WriteInt function, writing byte number of an address field in a first byte number storage area, wherein the length of the first byte number storage area can be 4 bytes, namely, writing a digital variable 100 in the first byte number storage area with the length of 4 bytes from the first address of a second transmission object, and calling a realloc function to increase the memory offset size _ t of the Pickle by 4; then, calling bits, namely aligning all bytes of an address field according to a preset number for aligning all bytes of a name field and optimizing memory arrangement, wherein the preset number can be 4 bytes or 8 bytes; finally, calling the WriteData function, writing the aligned address field in the address field storage area, that is, after the first byte storage area with the length of 4 bytes, starting to write the aligned address field with 100 bytes, and calling the realloc function to increase the memory offset size _ t of the Pickle by 100. Therefore, after writing the address field into the second transfer object, the memory size of the second transfer object is 104 bytes.
Referring to fig. 4, the sub-step S1022 may include the following sub-steps:
and a substep S10221 of obtaining the byte number of the address field.
In the embodiment of the present invention, a strlen function is called to obtain the number of bytes of an address field, and the number of bytes of the address field may be 100.
In the substep S10222, the byte number of the address field is written in the first byte number storage area.
In the embodiment of the present invention, the length of the first byte storage area may be 4 bytes, the WriteInt function may be called to write the digital variable 100 from the first address of the second transfer object to the first byte storage area with a length of 4 bytes, and the realloc function is called to increase the memory offset size _ t of the Pickle by 4.
The sub-step S10223 aligns all bytes of the address field by a preset number.
In the embodiment of the invention, a bits function is called, all bytes of an address field are aligned according to a preset number, the preset number can be 4 bytes or 8 bytes, and the alignment is used for aligning all bytes of a name field, so that the memory arrangement is optimized.
In the substep S10224, the aligned address field is written in the address field storage area.
In the embodiment of the invention, the WriteData function is called, after the first byte storage area with the length of 4 bytes, the aligned address field with 100 bytes is written, and simultaneously, the realloc function is called to increase the memory offset size _ t of the Pickle by 100.
And a substep S1023 of writing a name field into the second transfer object, wherein the address field occupies a first storage area of the second transfer object, the name field occupies a second storage area of the second transfer object, and addresses of the first storage area and the second storage area are continuous.
In the embodiment of the present invention, after the name field is acquired, the name field may be written into a second storage area of the second transmission object, where addresses of the second storage area and the first storage area are consecutive. The second storage area may include a second byte count storage area and a name field storage area, and addresses of the second byte count storage area and the name field storage area are consecutive. And writing the name field into the second transmission object, namely writing the byte number of the name field into a second byte number storage area, and writing all the bytes of the name field into the name field storage area.
As an embodiment, the method for writing the name field into the second transport object may be: firstly, calling a strlen function to acquire the number of bytes of a name field, wherein the number of bytes can be 100; secondly, calling a WriteInt function, writing the byte number of a name field in a second byte storage area, wherein the length of the second byte storage area can be 4 bytes, namely, writing a digital variable 100 in the second byte storage area with the length of 4 bytes behind an address field storage area with the length of 100 bytes, and simultaneously calling a realloc function to increase the memory offset size _ t of the Pickle by 4; then, calling bits, namely aligning all bytes of the name field according to a preset number, aligning all bytes of the name field with all bytes of the address field, and optimizing memory arrangement, wherein the preset number can be 4 bytes or 8 bytes; finally, calling the WriteData function, writing the aligned address field in the name field storage area, that is, after the second byte storage area with the length of 4 bytes, starting to write the aligned address field with 100 bytes, and calling the realloc function to increase the memory offset size _ t of the Pickle by 100. Thus, after writing the name field to the second transfer object, the memory size of the second transfer object is 208 bytes.
Referring to fig. 5, the sub-step S1023 may include the following sub-steps:
and a substep S10231 of obtaining the byte number of the name field.
In the embodiment of the present invention, a strlen function is called to obtain the number of bytes of a name field, and the number of bytes of the name field may be 100.
And a substep S10232, writing the byte number of the name field in the second byte number storage area.
In the embodiment of the present invention, the length of the second byte storage area may be 4 bytes, a WriteInt function may be called, the digital variable 100 is written in the second byte storage area with the length of 4 bytes after the address field storage area with 100 bytes, and a realloc function is called to increase the memory offset size _ t of the Pickle by 4.
And a sub-step S10233 of aligning all bytes of the name field by a preset number.
In the embodiment of the invention, a bits function is called, all bytes of a name field are aligned according to a preset number, the alignment is used for aligning all bytes of an address field, and the memory arrangement is optimized, wherein the preset number can be 4 bytes or 8 bytes.
In sub-step S10234, the aligned name field is written in the name field storage area.
In the embodiment of the present invention, the WriteData function is called, after the second byte storage area with the length of 4 bytes, the address field of 100 bytes after alignment starts to be written, the realloc function is called to increase the memory offset size _ t of Pickle by 100 at the same time, and after the address field and the name field are all written into the second transfer object, the memory size of the second transfer object is 208 bytes.
Step S103, sending the data of the second transmission object to other terminal devices.
In the embodiment of the invention, after the data of the first transmission object is written into the second transmission object, namely after the address field and the name field of the first transmission object are written into the second transmission object, firstly, a data function is called to return a memory pointer of the second transmission object, and a size function is called to return the memory size of the second transmission object; secondly, acquiring a second transmission object according to the memory pointer and the size of the memory; and finally, calling a network transmission interface, and sending the data of the second transmission object to other terminal equipment through a network. Other terminal devices may be, but are not limited to, smart phones, Personal Computers (PCs), tablet PCs, Personal Digital Assistants (PDAs), Mobile Internet Devices (MIDs), web servers, and the like.
Referring to fig. 6, step S103 may include the following sub-steps:
and a substep S1031, obtaining a memory pointer of the second transmission object.
In the embodiment of the invention, a data function can be called to return the memory pointer of the second transmission object Pickle.
In the sub-step S1032, the memory size of the second transmission object is obtained.
In the embodiment of the invention, a size function can be called to return the memory size of the second transmission object Pickle.
And a substep S1033 of obtaining the second transmission object according to the memory pointer and the memory size.
In the embodiment of the invention, the second transmission object Pickle is found according to the memory pointer returned by the data function and the memory size returned by the size function.
And a substep S1034, calling a network transmission interface, and sending the data of the second transmission object to other terminal devices.
In the embodiment of the present invention, a network transmission interface is called, and the data of the second transmission object is sent to other terminal devices such as a smart phone, a Personal Computer (PC), a tablet PC, a Personal Digital Assistant (PDA), a Mobile Internet Device (MID), a web server, and the like through a network.
In the embodiment of the invention, the data of the first transmission object to be transmitted is written into the second transmission object, so that the size of the memory of the second transmission object is consistent with the size of the data of the first transmission object, namely, the memory of the first transmission object is reduced by nearly 50%, and the memory occupied by the data of the transmission object is effectively reduced. And the data of the second transmission object is sent to other terminal equipment, so that the network communication transmission speed is obviously improved, and the method has good practicability.
Second embodiment
Referring to fig. 7, fig. 7 is a block diagram illustrating a data transmission apparatus 200 according to an embodiment of the invention. The data transmission device 200 includes an obtaining module 201, a data writing module 202, and a data sending module 203.
The obtaining module 201 is configured to obtain a first transmission object to be transmitted.
In this embodiment of the present invention, the obtaining module 201 may be configured to execute step S101.
The data writing module 202 is configured to write data of the first transmission object into a second transmission object, where a memory size of the second transmission object is consistent with a data size of the first transmission object.
In this embodiment of the present invention, the data writing module 202 may be configured to execute step S102.
Referring to fig. 8, fig. 8 is a block diagram illustrating a data writing module 202 in the data transmission apparatus 200 shown in fig. 7. The data writing module 202 includes a field acquiring unit 2021, an address field writing unit 2022, and a name field writing unit 2023.
A field obtaining unit 2021, configured to obtain an address field and a name field of the first transport object.
In an embodiment of the present invention, the field obtaining unit 2021 may be configured to perform the sub-step S1021.
An address field writing unit 2022, configured to write the address field into the second transfer object.
In an embodiment of the present invention, the address field writing unit 2022 may be configured to perform sub-step S1022.
Referring to fig. 9, fig. 9 is a block diagram illustrating an address field writing unit 2022 in the data writing module 202 shown in fig. 8. The address field writing unit 2022 includes a first byte count obtaining unit 20221, a first byte count writing unit 20222, a first execution unit 20223, and a second execution unit 20224.
A first byte count obtaining unit 20221, configured to obtain the byte count of the address field.
In an embodiment of the present invention, the first byte count obtaining unit 20221 may be configured to perform the sub-step S10221.
A first byte count writing unit 20222, for writing the byte count of the address field in the first byte count storage area.
In an embodiment of the present invention, the first byte count write unit 20222 may be configured to perform the substep S10222.
A first execution unit 20223, configured to align all bytes of the address field according to a preset number.
In an embodiment of the present invention, the first performing unit 20223 may be configured to perform the sub-step S10223.
A second execution unit 20224, configured to write the aligned address field in the address field storage area.
In an embodiment of the present invention, the second performing unit 20224 may be configured to perform the substep S10224.
A name field writing unit 2023, configured to write a name field into the second transfer object, where the address field occupies a first storage area of the second transfer object, the name field occupies a second storage area of the second transfer object, and addresses of the first storage area and the second storage area are consecutive.
In an embodiment of the present invention, the name field writing unit 2023 may be configured to perform the sub-step S1023.
Referring to fig. 10, fig. 10 is a block diagram illustrating the name field writing unit 2023 in the data writing module 202 shown in fig. 8. The name field writing unit 2023 includes a second byte count obtaining unit 20231, a second byte count writing unit 20232, a third execution unit 20233, and a fourth execution unit 20234.
A second byte count acquisition unit 20231, configured to acquire the byte count of the name field.
In this embodiment of the present invention, the second byte count obtaining unit 20231 may be configured to perform the sub-step S10231.
A second byte count writing unit 20232, configured to write the byte count of the name field in the second byte count storage area.
In the embodiment of the present invention, the second byte count writing unit 20232 may be configured to perform the sub-step S10232.
A third performing unit 20233, configured to align all bytes of the name field according to a preset number.
In an embodiment of the present invention, the third performing unit 20233 may be configured to perform the sub-step S10233.
A fourth execution unit 20234, configured to write the aligned name field in the name field storage area.
In an embodiment of the present invention, the fourth performing unit 20234 may be configured to perform the sub-step S10234.
And a data sending module 203, configured to send the data of the second transmission object to other terminal devices.
In this embodiment of the present invention, the data sending module 203 may be configured to execute step S103.
Referring to fig. 11, fig. 11 is a block diagram illustrating a data sending module 203 in the data transmission apparatus 200 shown in fig. 7. The data transmission module 203 includes a memory pointer obtaining unit 2031, a memory size obtaining unit 2032, a transmission object obtaining unit 2033, and a transmission unit 2034.
A memory pointer obtaining unit 2031, configured to obtain a memory pointer of the second transmission object.
In this embodiment of the present invention, the memory pointer obtaining unit 2031 may be configured to perform the substep S1031.
A memory size obtaining unit 2032, configured to obtain a memory size of the second transmission object.
In this embodiment of the present invention, the memory size obtaining unit 2032 may be configured to perform the sub-step S1032.
A transmission object obtaining unit 2033, configured to obtain the second transmission object according to the memory pointer and the memory size.
In an embodiment of the present invention, the transmission object acquiring unit 2033 may be configured to perform the substep S1033.
A sending unit 2034, configured to invoke the network transmission interface, and send the data of the second transmission object to the other terminal device.
In this embodiment of the present invention, the sending unit 2034 may be configured to perform sub-step S1034.
In summary, the data transmission method, apparatus and terminal device provided by the present invention include: acquiring a first transmission object to be transmitted; writing the data of the first transmission object into a second transmission object, wherein the memory size of the second transmission object is consistent with the data size of the first transmission object; and sending the data of the second transmission object to other terminal equipment. According to the invention, the data of the first transmission object to be transmitted is written into the second transmission object, so that the size of the memory of the second transmission object is consistent with the size of the data of the first transmission object, namely, the memory of the first transmission object is reduced by nearly 50%, the memory occupied by the data of the transmission object is effectively reduced, and then the data of the second transmission object is sent to other terminal equipment, so that the network communication transmission speed is obviously improved, and the method has good practicability.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.

Claims (8)

1. A data transmission method is applied to a terminal device, and the method comprises the following steps:
acquiring a first transmission object to be transmitted;
writing the data of the first transmission object into a second transmission object, wherein the memory size of the second transmission object is consistent with the data size of the first transmission object;
sending the data of the second transmission object to other terminal equipment;
the step of writing the data of the first transmission object into a second transmission object comprises the following steps:
acquiring an address field and a name field of the first transmission object;
writing the address field to the second transport object;
and writing the name field into the second transmission object, wherein the address field occupies a first storage area of the second transmission object, the name field occupies a second storage area of the second transmission object, and the addresses of the first storage area and the second storage area are continuous.
2. The method of claim 1, wherein the first storage area comprises a first byte count storage area and an address field storage area, wherein addresses of the first byte count storage area and the address field storage area are consecutive;
the step of writing the address field to the second transport object includes:
acquiring the byte number of the address field;
writing the byte number of the address field in the first byte number storage area;
aligning all bytes of the address field according to a preset number;
and writing the aligned address field in the address field storage area.
3. The method of claim 1, wherein the second storage area comprises a second byte count storage area and a name field storage area, wherein addresses of the second byte count storage area and the name field storage area are consecutive;
the step of writing the name field to the second transport object includes:
acquiring the number of bytes of the name field;
writing the byte number of the name field in the second byte number storage area;
aligning all bytes of the name field according to a preset number;
and writing the aligned name field in the name field storage area.
4. The method of claim 1, wherein the step of transmitting the data of the second transmission object to other terminal devices comprises:
acquiring a memory pointer of the second transmission object;
acquiring the memory size of the second transmission object;
acquiring the second transmission object according to the memory pointer and the memory size;
and calling a network transmission interface, and sending the data of the second transmission object to other terminal equipment.
5. A data transmission apparatus, applied to a terminal device, the apparatus comprising:
the acquisition module is used for acquiring a first transmission object to be transmitted;
a data writing module, configured to write data of the first transmission object into a second transmission object, where a memory size of the second transmission object is consistent with a data size of the first transmission object;
the data sending module is used for sending the data of the second transmission object to other terminal equipment;
wherein the data writing module comprises:
a field obtaining unit, configured to obtain an address field and a name field of the first transport object;
an address field writing unit, configured to write the address field into the second transport object;
a name field writing unit, configured to write the name field into the second transport object, where the address field occupies a first storage area of the second transport object, the name field occupies a second storage area of the second transport object, and addresses of the first storage area and the second storage area are consecutive.
6. The apparatus of claim 5, wherein the first storage area comprises a first byte count storage area and an address field storage area, wherein addresses of the first byte count storage area and the address field storage area are contiguous; the address field write unit includes:
a first byte number obtaining unit, configured to obtain a byte number of the address field;
a first byte number writing unit, configured to write the byte number of the address field in the first byte number storage area;
the first execution unit is used for aligning all bytes of the address field according to a preset number;
and the second execution unit is used for writing the aligned address field in the address field storage area.
7. The apparatus of claim 5, wherein the second storage area comprises a second byte count storage area and a name field storage area, wherein addresses of the second byte count storage area and the name field storage area are consecutive; the name field writing unit includes:
a second byte number obtaining unit, configured to obtain a byte number of the name field;
a second byte number writing unit, configured to write the byte number of the name field in the second byte number storage area;
a third execution unit, configured to align all bytes of the name field according to a preset number;
and the fourth execution unit is used for writing the aligned name field in the name field storage area.
8. A terminal device, characterized in that the terminal device comprises:
a memory;
a processor; and
a data transfer device stored in the memory and including one or more software function modules executed by the processor, comprising:
the acquisition module is used for acquiring a first transmission object to be transmitted;
a data writing module, configured to write data of the first transmission object into a second transmission object, where a memory size of the second transmission object is consistent with a data size of the first transmission object;
the data sending module is used for sending the data of the second transmission object to other terminal equipment;
wherein the data writing module comprises:
a field obtaining unit, configured to obtain an address field and a name field of the first transport object;
an address field writing unit, configured to write the address field into the second transport object;
a name field writing unit, configured to write the name field into the second transport object, where the address field occupies a first storage area of the second transport object, the name field occupies a second storage area of the second transport object, and addresses of the first storage area and the second storage area are consecutive.
CN201710789054.4A 2017-09-05 2017-09-05 Data transmission method and device and terminal equipment Active CN107689996B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710789054.4A CN107689996B (en) 2017-09-05 2017-09-05 Data transmission method and device and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710789054.4A CN107689996B (en) 2017-09-05 2017-09-05 Data transmission method and device and terminal equipment

Publications (2)

Publication Number Publication Date
CN107689996A CN107689996A (en) 2018-02-13
CN107689996B true CN107689996B (en) 2020-07-31

Family

ID=61155940

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710789054.4A Active CN107689996B (en) 2017-09-05 2017-09-05 Data transmission method and device and terminal equipment

Country Status (1)

Country Link
CN (1) CN107689996B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189505B (en) * 2018-07-06 2021-11-09 武汉斗鱼网络科技有限公司 Method and system for reducing storage space occupied by object serialization

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5897668A (en) * 1995-01-24 1999-04-27 Matsushita Electric Industrial Co., Ltd. Memory system for storing information data and state-of-radio-transmission data
CN1946087A (en) * 2006-09-30 2007-04-11 华为技术有限公司 Data transmission method and system between movable terminal and server end
CN101170393A (en) * 2007-12-04 2008-04-30 腾讯科技(深圳)有限公司 Data transmission method, data transmission device
CN101819561A (en) * 2010-04-21 2010-09-01 中兴通讯股份有限公司 File downloading method and system
CN101999113A (en) * 2008-04-04 2011-03-30 威睿公司 Method and system for storage replication
CN104901920A (en) * 2014-03-03 2015-09-09 联想(北京)有限公司 Data transmission control method and device and electronic equipment
CN106021153A (en) * 2016-05-16 2016-10-12 安徽华米信息科技有限公司 Data transmission method and device and intelligent electronic equipment
CN106844245A (en) * 2017-02-17 2017-06-13 北京腾凌科技有限公司 Data transmission method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5897668A (en) * 1995-01-24 1999-04-27 Matsushita Electric Industrial Co., Ltd. Memory system for storing information data and state-of-radio-transmission data
CN1946087A (en) * 2006-09-30 2007-04-11 华为技术有限公司 Data transmission method and system between movable terminal and server end
CN101170393A (en) * 2007-12-04 2008-04-30 腾讯科技(深圳)有限公司 Data transmission method, data transmission device
CN101999113A (en) * 2008-04-04 2011-03-30 威睿公司 Method and system for storage replication
CN101819561A (en) * 2010-04-21 2010-09-01 中兴通讯股份有限公司 File downloading method and system
CN104901920A (en) * 2014-03-03 2015-09-09 联想(北京)有限公司 Data transmission control method and device and electronic equipment
CN106021153A (en) * 2016-05-16 2016-10-12 安徽华米信息科技有限公司 Data transmission method and device and intelligent electronic equipment
CN106844245A (en) * 2017-02-17 2017-06-13 北京腾凌科技有限公司 Data transmission method and device

Also Published As

Publication number Publication date
CN107689996A (en) 2018-02-13

Similar Documents

Publication Publication Date Title
CN110113393B (en) Message pushing method and device, electronic equipment and medium
CN108390856B (en) DDoS attack detection method and device and electronic equipment
CN113660351B (en) Data communication method, device, communication terminal and computer readable storage medium
CN110764924A (en) Inter-core communication method and device of multi-core processor
US20200204688A1 (en) Picture book sharing method and apparatus and system using the same
CN110297722B (en) Thread task communication method and related product
CN110069217B (en) Data storage method and device
CN107689996B (en) Data transmission method and device and terminal equipment
CN112650804B (en) Big data access method, device, system and storage medium
CN112436943B (en) Request deduplication method, device, equipment and storage medium based on big data
CN109032693A (en) Method and device for loading display information, electronic equipment and readable storage medium
CN111078697B (en) Data storage method and device, storage medium and electronic equipment
CN112422485B (en) Communication method and device of transmission control protocol
CN111090623B (en) Data auditing method and device, electronic equipment and storage medium
CN110020290B (en) Webpage resource caching method and device, storage medium and electronic device
CN107124353B (en) Message processing method and device, computer device and storage medium
CN114124883B (en) Data access method and device based on cloud storage address, computer equipment and medium
CN113486025B (en) Data storage method, data query method and device
US10541963B2 (en) Common message sending method, electronic device, and storage medium
CN114006819A (en) Detection strategy generation and device, and data transmission method and device
CN113672488A (en) Log text processing method and device
CN111090633A (en) Small file aggregation method, device and equipment of distributed file system
CN113986134B (en) Method for storing data, method and device for reading data
CN114237509B (en) Data access method and device
WO2016091076A1 (en) Processing method for communication address in mobile communication terminal and mobile communication terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20231102

Address after: No. 101, 1st to 3rd floors, Building 42, Yard 5, Fengrun Middle Road, Haidian District, Beijing, 100080

Patentee after: Shi Benxia

Address before: 430000 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park East Road 4.1 Phase B1 Building 11 Building

Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20231130

Address after: Building 2, No. 1 Shangdi Information Road, Haidian District, Beijing, 100080, 2104

Patentee after: BEIJING YILING TECHNOLOGY CO.,LTD.

Address before: No. 101, 1st to 3rd floors, Building 42, Yard 5, Fengrun Middle Road, Haidian District, Beijing, 100080

Patentee before: Shi Benxia

TR01 Transfer of patent right