CN101202704B - Method and system for transmitting data - Google Patents

Method and system for transmitting data Download PDF

Info

Publication number
CN101202704B
CN101202704B CN 200710076929 CN200710076929A CN101202704B CN 101202704 B CN101202704 B CN 101202704B CN 200710076929 CN200710076929 CN 200710076929 CN 200710076929 A CN200710076929 A CN 200710076929A CN 101202704 B CN101202704 B CN 101202704B
Authority
CN
China
Prior art keywords
socket
data
write
reading
state
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.)
Expired - Fee Related
Application number
CN 200710076929
Other languages
Chinese (zh)
Other versions
CN101202704A (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.)
Shenzhen Coship Electronics Co Ltd
Original Assignee
Shenzhen Coship Electronics 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 Shenzhen Coship Electronics Co Ltd filed Critical Shenzhen Coship Electronics Co Ltd
Priority to CN 200710076929 priority Critical patent/CN101202704B/en
Publication of CN101202704A publication Critical patent/CN101202704A/en
Priority to PCT/CN2008/071577 priority patent/WO2009030130A1/en
Application granted granted Critical
Publication of CN101202704B publication Critical patent/CN101202704B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)

Abstract

The invention is applicable to the field of digital television and provides a method and a system which are used for data transmission. The method includes the following steps that a socket is set up and network connection require is transmitted; when the connection is judged to be successful, a notice slot of the socket is registered; whether data written by the socket is successful is judged and if yes, a response packet at the data receiving terminal is read; when the data writing is not successful, the socket added into a working array and the state of the socket is checked continuously and when the socket can be written, the data writing the socket is informed. The embodiment of the invention establishes a state machine through a common inquire mechanism. The socket carries through data circulation according to the state machine and realizes to inform the socket of the data circulation state timely and accurately through setting up an informing mechanism to the socket, thus effectively processing a network protocol and a network connection under the situation of large network concurrent amounts.

Description

A kind of transmission method of data and system
Technical field
The invention belongs to digital TV field, relate in particular to a kind of transmission method and system of data.
Background technology
In network server system, for the connection request of client, its processing mode adopts two kinds of models: a kind of is that receiving terminal adopts the iteration server model, handles the request of client successively; Another kind is that receiving terminal adopts the concurrent server model, produces a process for each client requests and goes to handle.Receiving terminal adopts the concurrent server model, derives from some subprocesss in advance and handles client requests; Receiving terminal adopts the concurrent server model, produces a thread for each client and goes to handle; Receiving terminal adopts the concurrent server model, derives from some threads in advance and goes to handle.
Prior art generally all is that receiving terminal adopts the concurrent server model, derives from some threads in advance and goes to handle client-requested, whenever there being a client-requested to come, just this request is submitted to a thread pool the inside, till this request is handled.
Prior art does not have the unreasonable of division or division or does not introduce this mechanism for the circulation of socket intermediateness, agreement implementation state and data executing state, and socket does not adopt informing mechanism or imperfection, when network event takes place, can not notify application layer in time, accurately.
Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of data transmission method, and it is big to be intended to solve in the prior art network data transmission concurrency, when network event takes place, can not promptly and accurately notify the network connectivity problem of application layer.
The embodiment of the invention is achieved in that a kind of sending method of data, and described method comprises the steps:
Set up socket, concurrent SCN Space Cable Network connection request;
When judging described successful connection, register the notice slot of described socket;
Judge by the whether success of described socket write data, when write data is successful, the response bag of reading of data receiving terminal then; When write data is unsuccessful, described socket is added work queue, and constantly detect the state of described socket, when described socket can be write, but notify described socket write data;
When described network is connected to file transfer, the Network Transmission flow of file data is judged that flow process comprises the steps:
Whether the Network Transmission flow of judging file data has surpassed preset value;
When the Network Transmission flow of described file data has surpassed preset value, return the write data user and wait for, and will join in the work queue;
Judge the state of described socket; When socket can be write, the notice socket read and write data.。
Another purpose of the embodiment of the invention is to provide a kind of method of reseptance of data, and described method comprises the steps:
Set up one and monitor socket, and judge whether successful described socket is monitored;
Judge whether described monitoring socket listens to network connecting request;
When successful connection, the socket of monitoring is reselected a new socket;
Judge by the whether success of described new socket reading of data, when reading of data is successful, the request package of reading of data transmitting terminal then; When reading of data is unsuccessful, described new socket is added work queue, and constantly detect the state of described new socket, when described new socket is readable, notify described new socket read data;
When described network is connected to file transfer, the Network Transmission flow of file data is judged that flow process comprises the steps:
Whether the Network Transmission flow of judging file data has surpassed preset value;
When the Network Transmission flow of described file data has surpassed preset value, return the read data user and wait for, and socket is joined in the work queue;
Judge the state of the described socket of inquiry; When socket was readable, the notice socket was read file data.。
Another purpose of the embodiment of the invention is to provide a kind of data Transmission system, and described system comprises:
Socket is set up module, is used to set up socket;
The connection request sending module is used to send network connecting request;
Notice slot Registering modules is used for registering the notice slot of described socket when judging described successful connection; And
Socket write data judging treatmenting module is used for judging by the whether success of described socket write data, when write data is successful, and the response bag of reading of data receiving terminal then; When write data is unsuccessful, described socket is added work queue, and constantly detect the state of described socket, when described socket can be write, but notify described socket write data;
Described socket write data judging treatmenting module also comprises:
Read Network Transmission flow judge module, be used to judge whether the Network Transmission flow of file data has surpassed preset value;
Read the flow processing module, be used for when the Network Transmission flow of described file data has surpassed preset value, returning and writing interruption, socket is joined in the work queue, and judge the state of inquiring about described socket, and when socket can be write, notice socket file data.
Another purpose of the embodiment of the invention is to provide a kind of data receiving system, and described system comprises:
Monitor socket and set up judge module, be used to set up one and monitor socket, and judge whether successful described socket is monitored;
The connection request judge module is used to judge whether described monitoring socket listens to network connecting request;
New socket is selected module, is used for when successful connection, and the socket of monitoring can be reselected a new socket; And
Socket reading of data judging treatmenting module is used for judging by the whether success of described new socket reading of data, when reading of data is successful, and the request package of reading of data transmitting terminal then; When reading of data is unsuccessful, described new socket is added work queue, and constantly detect the state of described new socket, when described new socket is readable, notify described new socket read data;
Described socket reading of data judging treatmenting module also comprises:
Write Network Transmission flow judge module, be used to judge whether the Network Transmission flow of file data has surpassed preset value;
Write the flow processing module, be used for when the Network Transmission flow of described file data has surpassed preset value, return and read to interrupt, socket is joined in the work queue, and judge the state of inquiring about described socket, when socket was readable, the notice socket read file data.
The embodiment of the invention is by general inquiry mechanism, socket is set up state machine, socket carries out the data circulation according to state machine, and socket set up an informing mechanism, realize the state of notice socket data circulation promptly and accurately, under the very big situation of network concurrency, effectively handled procotol and network and connected like this.
Description of drawings
Fig. 1 is the realization flow figure of the sending method of the network data that provides of the embodiment of the invention;
Fig. 2 is the response bag realization flow figure that socket that the embodiment of the invention provides reads receiving terminal;
Fig. 3 is the detection realization flow figure that reads the Network Transmission flow of the file that provides of the embodiment of the invention;
Fig. 4 is the realization flow figure of the method for reseptance of the network data that provides of the embodiment of the invention;
Fig. 5 is that the socket that the embodiment of the invention provides writes response bag realization flow figure;
Fig. 6 is the detection realization flow figure that writes network traffics of the file that provides of the embodiment of the invention;
Fig. 7 is the structure chart of the data transmission system that provides of the embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
The embodiment of the invention is by general inquiry mechanism, socket is set up state machine, socket carries out the data circulation according to state machine, and socket set up an informing mechanism, realize the state of notice socket data circulation promptly and accurately, under the very big situation of network concurrency, effectively handled procotol and network and connected like this.
In embodiments of the present invention, the state of socket (socket) is defined as follows:
Input/output interface io opens: after a socket was set up, its state just became the io open mode;
Io monitors: after a socket was monitored successfully, its state just became io and monitors;
Io etc. are to be connected: the state before this socket request connects;
The io free time: what input/output interface i/o temporarily do not have do;
The io idle waiting: general because the i/o that speed restriction causes does not go to read and write data, after lowering, uniform velocity just can read and write;
Io etc. continue: this generally is owing to temporarily do not read the data that data or we such as send after the data at the other side to be read, perhaps because the inbound pacing of restricting data and do not read data;
Io etc. are to be written: this generally is not have the state of write data owing to temporary transient write data failure or in order to control transmission speed;
Io test: be used for testing the i/o state;
Io waits for and closing: this i/o will close at once;
The io mistake: i/o makes a mistake;
Io closes: i/o is carrying out shutoff operation;
Io closes end: i/o closes;
Io is placed into the release formation: for recycling this i/o, after it finishes, put it into formation, wait for that others takes once more.
And the circulation state of protocol data is defined as follows:
Initialization: protocol initializing stage;
Read: socket has read the network data that is over;
Read: socket is reading network data;
The read data user waits for: when after network reads data, will preserve data to buffering or written document, this state generally is used for speed restriction, when speed greater than some threshold values the time, just allow written document be in wait state, till speed lowers;
Socket reads to wait for: socket does not temporarily read data, the socket that is in this state can join work queue, when the another one thread inquires the readable incident of this socket, send a notification message to this socket, notify this socket to go reading of data;
Write: socket has write the network data that is over;
Write: socket is writing network data;
Write data user waits for: this state is for speed restriction, when write data, at first will reach data from file or buffering, when transmission speed is too fast, for speed restriction, will allow the user temporarily get less than data, till speed lowers;
Socket writes wait: this generally causes owing to generation socket writes the i/o obstruction, the socket that is in this state will join the service area, the another one thread can be inquired about this socket, sends when this socket can write and can write notification message, and this socket goes write data more then;
Handle: the protocol data analyzing and processing finishes;
Handle: just at the analyzing and processing protocol data;
Handle and wait for: in general, we are to be submitted to go in the new thread to handle when handling a request msg, and at this moment main thread just returns the processing wait state;
Mistake: this state follows the socket mistake to handle together;
Preparation is closed: after protocol data all disposes, state is changed to the preparation closed condition;
Close: agreement is closed, and prepares to close socket afterwards.
Fig. 1 shows the realization flow of the sending method of the network data that the embodiment of the invention provides, and its detailed step is as described below:
In step S101, set up a socket, wherein the state of this socket is an open mode, the data protocol state is an init state.
In step S102, transmitting terminal sends connection request to receiving terminal, and this moment, the state of socket was etc. to be connected.
In step S103, whether the connection of determining step S102 success, is execution in step S105 then, otherwise execution in step S104.
In step S104, close above-mentioned socket, program is directly returned.
In step S105, the notice slot slot of registration socket.
In embodiments of the present invention, it is Isocket and IsocketSlot that 2 classes are arranged in program, Isocket has encapsulated the socket operation specially, IsocketSlot is used to provide notified function specially, and Isocket remains with IsocketSlot, and IsocketSlot also remains with Isocket, when sending request, if the socket successful connection so just associates corresponding IsocketSlot and this Isocket, the process of registration that Here it is.
In step S106, generate protocol data, and store this protocol data into buffering area, be ready for sending protocol data, the state of protocol data is for writing state at this moment, and wherein this protocol data comprises statusline, head and inclusion.
In step S107, by socket to the receiving terminal write data.
In step S108, judge the whether success of socket write data, be execution in step S109 then; Otherwise execution in step S110.Wherein, write data is that piecemeal is write on network, and for example every 4K is one and sends.
In step S109, the socket write data is finished, and promptly data file sends and finishes, and the protocol data state is the write data state, and then, socket reads the response of receiving terminal, and the state of socket is for reading at this moment.
In embodiments of the present invention, after socket ran through the response of protocol data, the presentation protocol data sent and finish, and promptly connected and finished; Get nowhere if read to respond, so this socket is joined formation, and whether constantly inquire about this formation readable, read response when readable again, close socket then, whole protocol interaction finishes.
In step S110, socket write data failure, this moment, the socket state was the socket error condition, and the protocol data state to be socket write wait state, simultaneously socket is joined certain work queue.
In step S111, new thread is constantly inquired about the state of the socket in the above-mentioned work queue, judges whether the state of socket becomes and can write, and is execution in step S112 then, otherwise execution in step S113.
In step S112, transmitting terminal sends to above-mentioned socket can write message, and returns execution in step S108, and in embodiments of the present invention, this cyclic process exists always, sends up to data file to finish.
In step S113, wait for, can write state up to socket, and execution in step S111 once more.
In embodiments of the present invention, data transmission procedure is to adopt based on transmission control protocol (TransmissionControl Protocol, TCP) agreement, this Transmission Control Protocol mainly is HTML (Hypertext Markup Language) (Hyper TextTransfer Protocol, HTTP), real-time streaming protocol (Real Time Streaming Protocol, RTSP) and custom protocol.
In embodiments of the present invention, socket is assigned in the service area, wherein the processing for I/O is divided into a lot of service areas, the I/O that handle each service area has certain restriction, for example 1024 sockets can only be handled in each service area at every turn, are handled by first service area at present and monitor and all the other remaining I/O, if socket number to be processed is many, just increase the service area, the service area of increase can be withdrawed from after work disposal is finished; If the socket number has lacked, just reduce the service area.Each service area is by a thread process, the number of the each inquiry of general windows system default is 64, the linux number of acquiescence down is 1024,130 sockets are handled in each service area under windows, 1024 sockets are handled in each service area under linux, the thread of handling each service area is always all in operation, and each socket of this service area of circular treatment is adjusted like this and made that the network concurrent processing is very capable.Speed and efficient have been guaranteed.Wherein, socket always the placement in non-plug patterns.
As one embodiment of the present of invention, there are two kinds of situations in the response that socket reads receiving terminal, be protocol interaction and file transfer, in embodiments of the present invention, protocol interaction comprises request, handles and responds, and these three steps can represent that this protocol interaction process finishes, and the process of file transfer is the process of a circulation, file transfer is finished by piecemeal, and the transmission of each block file all is the process of a complete protocol interaction.The following detailed process that provides is described:
In step S201, judge the whether success of response bag read receiving terminal, be execution in step S202 then, otherwise execution in step S203.
In step S202, read the response bag of receiving terminal, this moment, the protocol data state was a read states, handled the response of receiving terminal simultaneously.
In embodiments of the present invention, program is divided into application layer and bottom, after bottom reads response, response is submitted to application layer process, for example registers a kind of transmission means, send request and after service end responds to service end in client, client has read the response bag of service end, to respond bag then and be submitted to the assembly of registering transmission means just now, and, then not need to have registered again if succeed in registration, if registration is unsuccessful, then can constantly register, till success, certain different response process mode difference, business demand is also different, the response that has does not need to handle, but as the reciprocal process of an agreement, whole flow process will finish.
After disposing, the socket state is for closing, and the protocol data state also is a closed condition, and whole protocol interaction process finishes.
In step S203, do not read the response bag of receiving terminal, the socket state variation is the socket mistake, the protocol data state variation is that socket reads to wait for, at this moment, socket is joined work queue.
In step S204, new thread is constantly inquired about the state of this socket, judges promptly whether socket is readable, is execution in step S205 then, otherwise execution in step S206.
In step S205, notice socket reads and responds bag, returns execution in step S201 simultaneously.
In step S206, continue inquiry, readable up to socket.
If it is normal protocol interaction that above-mentioned network connects, socket only reads the response bag of a receiving terminal so.
If above-mentioned connection is a file transfer, then repeatedly to read between transmitting terminal and the receiving terminal and respond bag, i.e. circulation is read.
In embodiments of the present invention, be connected to the situation of file transfer for network, as described in Figure 3, whether the flow that reads network surpassed set point detect, its detailed step is as described below:
In step S301, judge whether read the Network Transmission flow surpasses set point, be execution in step S302 then, otherwise finish, in embodiments of the present invention, this judgement promptly is to judge that whether the file flow that transmits in the current network surpasses preset value, transmits because file transfer is a piecemeal, when minute block size surpasses preset value, be and exceed the predetermined network delivery flow rate.
In step S302, in the written document process, to return and write interruption, this moment, the protocol data state variation waited for that for the read data user socket state temporarily becomes the idle waiting state.
In step S303, socket is joined in the work queue.
In step S304, new thread is constantly inquired about the state of the socket in the above-mentioned work queue, judges promptly whether above-mentioned socket is readable, is execution in step S305 then, continues inquiry otherwise carry out.
In step S305, notice socket reads file data.
In step S306, constantly read in the process of file data at socket, judge whether reading of data is successful, is then to continue to read, otherwise execution in step S308.
In step S307, the socket state becomes error condition, and the protocol data state variation is that socket reads to wait for, this socket is joined work queue.
In step S308, the another one new thread is constantly inquired about the state of this socket, judges promptly whether socket is readable, is execution in step S309 then, otherwise continues inquiry.
In step S309, notify this socket reading of data, so repeatedly till file runs through.
Just effectively control network traffics by above-mentioned realization flow, realized the transmission of file data.
Fig. 4 shows the realization flow of the method for reseptance of the network data that the embodiment of the invention provides, and its detailed step is as described below:
In step S401, set up one and monitor socket.
In step S402, judge that socket monitors whether success, whether the connection request of some ip address and port is promptly arranged, be execution in step S404 then, otherwise execution in step S403.
In step S403, close this socket and return.
In step S404, will monitor socket and join work queue, the state of this socket is a listening state.
In step S405, new thread is constantly inquired about the monitoring socket in the service area.
In step S406, constantly inquire about according to above-mentioned new thread, judge whether to listen to the connection request of transmitting terminal, be execution in step S407 then, otherwise finish, close this monitoring socket.
In step S407, monitor socket new socket of accept again.
In embodiments of the present invention, the connection that listens to is submitted in the linear formation, receiving terminal is opened up this connection that a thread process listens to specially.
In step S408, judge again the whether success of new socket reading of data of accept, this moment, the protocol data state was just at read states, was execution in step S413 then, otherwise execution in step S409.
In step S409, new socket reading of data is unsuccessful, and this moment, this socket state variation was the socket mistake, and the protocol data state variation is the socket read error, shows temporarily to read less than data, simultaneously this socket is joined in the work queue.
In step S410, new thread is constantly inquired about the state of new socket.
In step S411, it is readable whether the state of judging new socket becomes, and is execution in step S412 then, otherwise continues inquiry, and return this step.
In step S412, receiving terminal sends readable notification message to new socket, and returns execution in step S408.
In step S413, after reading of data finished, the protocol data state variation was a read states, beginning analyzing and processing protocol data, and this moment, the protocol data state variation was for just at treatment state.
In step S414, receiving terminal is write the response data, and this moment, socket state limit was for writing.
As another embodiment of the present invention, receiving terminal is write the response packet and is drawn together two kinds of situations, it is the mutual and file transfer of normal protocol, in embodiments of the present invention, protocol interaction comprises request, handles and responds, and these three steps can represent that this protocol interaction process finishes, and the process of file transfer is the process of a circulation, file transfer is finished by piecemeal, and the transmission of each block file all is the process of a complete protocol interaction.Followingly provide detailed description:
In step S501, judge to write and respond whether success of bag, be execution in step S502 then, otherwise execution in step S503.
In step S502, respond bag and write success, the protocol data state is closed socket for writing state at this moment.
After disposing, the socket state is for closing, and the protocol data state also is a closed condition, and the protocol interaction process finishes, if file transfer then can only just can be closed this socket after the file transfer of all piecemeals is finished.
In step S503, write failure if respond bag, the socket state variation is the socket mistake, the protocol data state variation is that socket writes wait, at this moment, socket is joined work queue.
In step S504, new thread is constantly inquired about the state of this socket.
In step S505, judge whether socket can write, be execution in step S506 then, otherwise execution in step S507.
In step S506, notice socket writes and responds bag, returns execution in step S501 simultaneously.
In step S507, continue inquiry, can write up to socket.
If it is normal protocol interaction that above-mentioned network connects, then writes and once respond bag.
If above-mentioned connection is the transmission of file, then receiving terminal is repeatedly write to data sending terminal and is responded bag, and the piecemeal of a file of every transmission all will be write response, and it is as described below wherein whether the flow of network to be surpassed the detailed process of detection of set point:
In step S601, judge that whether the flow of the network of file data surpasses set point, be execution in step S602 then, otherwise finish.
In step S602, in reading the file process, to return and read to interrupt, this moment, the protocol data state variation waited for that for the write data user socket state temporarily becomes the idle waiting state.
In step S603, socket is joined in the work queue.
In step S604, new thread is constantly inquired about the state of the socket in the above-mentioned work queue, judges promptly whether above-mentioned socket can write, and is execution in step S605 then, continues inquiry otherwise carry out.
In step S605, notice socket file data.
In step S606, in the process of the continuous file data of socket, judge whether write data is successful, is then to continue to read, otherwise execution in step S607.
In step S607, the socket state becomes error condition, and the protocol data state variation is that socket writes wait, and this socket is joined work queue.
In step S608, the another one new thread is constantly inquired about the state of this socket, judges promptly whether socket can write, and is execution in step S609 then, otherwise continues inquiry.
In step S609, notify this socket write data, so repeatedly till file runs through.
Fig. 7 shows the structure chart of the data transmission system that the embodiment of the invention provides, the part relevant with the embodiment of the invention only is shown for convenience of explanation, wherein, data Transmission system 1 and data receiving system 2 place software unit, hardware cell or the software and hardware unit of terminal.
Data Transmission system 1 comprises that socket sets up module 11, connection request sending module 12, notice slot Registering modules 13 and socket write data judging treatmenting module 14, wherein:
Socket is set up module 11 and is set up socket; Connection request sending module 12 sends network connecting request; When judging this successful connection, the notice slot of notice slot Registering modules 13 these sockets of registration; Socket write data judging treatmenting module 14 judges by the whether success of this socket write data, when the write data success, and the response bag of reading of data receiving terminal then; When write data is unsuccessful, this socket is added work queue, and constantly detect the state of this socket, when this socket can be write, but notify this socket write data.
As one embodiment of the present of invention, the socket write data is handled judge module 14 and is comprised that also reading response wraps judge module 141, reads and respond packet handing module 142 and read response bag judging treatmenting module 143, wherein:
Read response bag judge module 141 and judge whether the response bag that reads receiving terminal is successful; When the response of reading receiving terminal is bundled into merit, reads and respond 142 processing responses of packet handing module bag; When the response bag that reads receiving terminal is unsuccessful, read response bag judging treatmenting module 143 this socket is joined work queue, and constantly detect the state of socket, when socket is readable, the response bag of reading of data receiving terminal.
In embodiments of the present invention, socket write data judging treatmenting module 14 also comprises to be read network traffics judge module 144 and reads flow processing module 145, reads network traffics judge module 144 and judges whether the Network Transmission flow of file data has surpassed preset value; When the Network Transmission flow of this document data has surpassed preset value, read flow processing module 145 and return and write interruption, socket is joined in the work queue, and judge the state of inquiry socket, when socket was readable, notice socket read file data.
Data receiving system 2 comprises that monitoring socket sets up judge module 21, connection request judge module 22, new socket selection module 23 and socket reading of data judging treatmenting module 24, wherein:
The monitoring socket is set up judge module 21 and is set up a monitoring socket, and judges whether this socket monitors successful; Connection request judge module 22 judges whether monitor socket listens to network connecting request; When successful connection, the socket that new socket selection module 23 is monitored is new socket of accept again; Socket reading of data judging treatmenting module 24 judges by the whether success of new socket reading of data, when reading of data is successful, and the request package of reading of data transmitting terminal then; When reading of data is unsuccessful, new socket is added work queue, and constantly detect the state of new socket, when new socket is readable, notify new socket readable data.
As another embodiment of the present invention, socket reading of data judging treatmenting module 24 comprises writing to be responded bag judge module 241, write response packet handing module 242 and writes response bag judging treatmenting module 243, wherein:
Write response bag judge module 241 and judge whether successful write response wraps; Respond when being bundled into merit when writing, write and respond packet handing module 242 and close this socket; Write and respond bag judging treatmenting module 243 and respond bag when unsuccessful, should join work queue by new socket, and constantly detect the state of this new socket, when this new socket can be write, write response and wrap when writing.
In embodiments of the present invention, socket reading of data judging treatmenting module 24 also comprises to be write network traffics judge module 244 and writes flow processing module 245, wherein:
Write network traffics judge module 244 and judge whether the Network Transmission flow of file data has surpassed preset value; When the Network Transmission flow of file data has surpassed predefined value, write the flow processing module and return and read to interrupt, socket is joined in the work queue, and judge the state of socket, when socket can write, notice socket sent file data.
The embodiment of the invention is by general inquiry mechanism, socket is set up state machine, socket carries out the data circulation according to state machine, and socket set up an informing mechanism, realize the state of notice socket data circulation promptly and accurately, under the very big situation of network concurrency, effectively handled procotol and network and connected like this.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (8)

1. the sending method of data is characterized in that, described method comprises the steps:
Set up socket, concurrent SCN Space Cable Network connection request;
When judging described successful connection, register the notice slot of described socket;
Judge by the whether success of described socket write data, when write data is successful, the response bag of reading of data receiving terminal then; When write data is unsuccessful, described socket is added work queue, and constantly detect the state of described socket, when described socket can be write, but notify described socket write data;
When described network is connected to file transfer, the Network Transmission flow of file data is judged that flow process comprises the steps:
Whether the Network Transmission flow of judging file data has surpassed preset value;
When the Network Transmission flow of described file data has surpassed preset value, return the write data user and wait for, and will join in the work queue;
Judge the state of described socket; When socket can be write, the notice socket read and write data.
2. the sending method of data as claimed in claim 1 is characterized in that, the response bag of described reading of data receiving terminal further comprises the steps:
Judge whether the response bag that reads receiving terminal is successful;
When described response of reading receiving terminal is bundled into merit, then handle described response bag;
When the described response bag that reads receiving terminal gets nowhere, described socket is joined work queue, and constantly detect the state of described socket, when described socket is readable, the response bag of reading of data receiving terminal.
3. the method for reseptance of data is characterized in that, described method comprises the steps:
Set up one and monitor socket, and judge whether successful described socket is monitored;
Judge whether described monitoring socket listens to network connecting request;
When successful connection, the socket of monitoring is reselected a new socket;
Judge by the whether success of described new socket reading of data, when reading of data is successful, the request package of reading of data transmitting terminal then; When reading of data is unsuccessful, described new socket is added work queue, and constantly detect the state of described new socket, when described new socket is readable, notify described new socket read data;
When described network is connected to file transfer, the Network Transmission flow of file data is judged that flow process comprises the steps:
Whether the Network Transmission flow of judging file data has surpassed preset value;
When the Network Transmission flow of described file data has surpassed preset value, return the read data user and wait for, and socket is joined in the work queue;
Judge the state of the described socket of inquiry; When socket was readable, the notice socket was read file data.
4. the method for reseptance of data as claimed in claim 3 is characterized in that, write data are responded bag and further comprised the steps:
Judge whether successful write response wraps;
Respond when being bundled into merit when described writing, then close described socket;
Respond bag when unsuccessful when described writing, described new socket is joined work queue, and constantly detect the state of described new socket, when described new socket can be write, write to respond and wrap.
5. a data Transmission system is characterized in that, described system comprises:
Socket is set up module, is used to set up socket;
The connection request sending module is used to send network connecting request;
Notice slot Registering modules is used for registering the notice slot of described socket when judging described successful connection; And
Socket write data judging treatmenting module is used for judging by the whether success of described socket write data, when write data is successful, and the response bag of reading of data receiving terminal then; When write data is unsuccessful, described socket is added work queue, and constantly detect the state of described socket, when described socket can be write, but notify described socket write data;
Described socket write data judging treatmenting module also comprises:
Read Network Transmission flow judge module, be used to judge whether the Network Transmission flow of file data has surpassed preset value;
Read the flow processing module, be used for when the Network Transmission flow of described file data has surpassed preset value, returning and writing interruption, socket is joined in the work queue, and judge the state of inquiring about described socket, and when socket can be write, notice socket file data.
6. data Transmission system as claimed in claim 5 is characterized in that, described socket write data judging treatmenting module also comprises:
Read and respond the bag judge module, be used to judge whether the response bag that reads receiving terminal is successful;
Read the response packet handing module, be used for when described response of reading receiving terminal is bundled into merit, then handling described response bag; And
Read and respond the bag judging treatmenting module, be used for when the described response bag that reads receiving terminal gets nowhere, described socket being joined work queue, and constantly detecting the state of described socket, when described socket is readable, the response bag of reading of data receiving terminal.
7. a data receiving system is characterized in that, described system comprises:
Monitor socket and set up judge module, be used to set up one and monitor socket, and judge whether successful described socket is monitored;
The connection request judge module is used to judge whether described monitoring socket listens to network connecting request;
New socket is selected module, is used for when successful connection, and the socket of monitoring is reselected a new socket; And
Socket reading of data judging treatmenting module is used for judging by the whether success of described new socket reading of data, when reading of data is successful, and the request package of reading of data transmitting terminal then; When reading of data is unsuccessful, described new socket is added work queue, and constantly detect the state of described new socket, when described new socket is readable, notify described new socket read data;
Described socket reading of data judging treatmenting module also comprises:
Write Network Transmission flow judge module, be used to judge whether the Network Transmission flow of file data has surpassed preset value;
Write the flow processing module, be used for when the Network Transmission flow of described file data has surpassed preset value, return and read to interrupt, socket is joined in the work queue, and judge the state of inquiring about described socket, when socket was readable, the notice socket read file data.
8. data receiving system as claimed in claim 7 is characterized in that, described socket reading of data judging treatmenting module also comprises:
Write response bag judge module, be used for judging whether successful write response wraps;
Write the response packet handing module, be used for responding when being bundled into merit, then close described socket when described writing;
Write and respond the bag judging treatmenting module, be used for responding bag when unsuccessful, described new socket is joined work queue, and constantly detect the state of described new socket, when described new socket can be write, write to respond and wrap when described writing.
CN 200710076929 2007-09-07 2007-09-07 Method and system for transmitting data Expired - Fee Related CN101202704B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN 200710076929 CN101202704B (en) 2007-09-07 2007-09-07 Method and system for transmitting data
PCT/CN2008/071577 WO2009030130A1 (en) 2007-09-07 2008-07-08 A method and system for transmitting data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200710076929 CN101202704B (en) 2007-09-07 2007-09-07 Method and system for transmitting data

Publications (2)

Publication Number Publication Date
CN101202704A CN101202704A (en) 2008-06-18
CN101202704B true CN101202704B (en) 2010-08-18

Family

ID=39517677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200710076929 Expired - Fee Related CN101202704B (en) 2007-09-07 2007-09-07 Method and system for transmitting data

Country Status (2)

Country Link
CN (1) CN101202704B (en)
WO (1) WO2009030130A1 (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101202704B (en) * 2007-09-07 2010-08-18 深圳市同洲电子股份有限公司 Method and system for transmitting data
CN102546733B (en) * 2010-12-31 2015-09-02 海信集团有限公司 Data communications method and device
CN103067788A (en) * 2012-12-17 2013-04-24 四川长虹电器股份有限公司 Electric appliance control method based on intelligent television
CN103384265B (en) * 2013-05-23 2016-04-06 上海斐讯数据通信技术有限公司 The application layer implementation method of GVRP agreement and system
CN103338156B (en) * 2013-06-17 2016-08-24 南京国电南自美卓控制***有限公司 A kind of name pipeline server concurrent communication method based on thread pool
CN103501245B (en) * 2013-09-26 2017-02-08 北京搜狐互联网信息服务有限公司 Network-event processing method and device
WO2016106780A1 (en) * 2015-01-04 2016-07-07 华为技术有限公司 User data transmission method and apparatus and terminal
CN107360059B (en) * 2017-07-28 2019-03-01 Oppo广东移动通信有限公司 Network detecting method, network detection device and intelligent terminal
CN108833469A (en) * 2018-04-27 2018-11-16 厦门理工学院 The resource transmission method, device and terminal device of a kind of terminal to terminal
CN111311471B (en) * 2019-01-25 2023-04-28 上海雪湖信息科技有限公司 Batch picture segmentation scheduling processing synthesis system and method based on FPGA (field programmable Gate array) calculation
CN110198312B (en) * 2019-05-23 2021-12-24 北京华三通信技术有限公司 Message processing method and device
CN110213177B (en) * 2019-06-06 2022-12-20 上海华测导航技术股份有限公司 Time-sharing sending method based on 4g module
CN111683138B (en) * 2020-06-05 2023-06-16 中国有色金属长沙勘察设计研究院有限公司 Socket-based efficient custom data transmission method
CN114363428B (en) * 2022-01-06 2023-10-17 齐鲁空天信息研究院 Socket-based data transmission method
CN114860483B (en) * 2022-06-17 2023-05-30 中国人民解放军陆军炮兵防空兵学院 Method and system for quickly collecting equipment data and realizing high-efficiency persistence

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1725757A (en) * 2004-07-21 2006-01-25 三星电子株式会社 Management is connected with the inspection socket

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100489942B1 (en) * 2003-02-18 2005-05-17 삼성전자주식회사 method of data transmission between processor using socket communication
CN1327724C (en) * 2004-06-28 2007-07-18 华为技术有限公司 Method for transmitting SABP news by ICP
CN1257630C (en) * 2004-09-30 2006-05-24 西安西电捷通无线网络通信有限公司 Method for moving node passing through NAT registration
CN101202704B (en) * 2007-09-07 2010-08-18 深圳市同洲电子股份有限公司 Method and system for transmitting data

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1725757A (en) * 2004-07-21 2006-01-25 三星电子株式会社 Management is connected with the inspection socket

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
程超等.基于Java非阻塞I/O开发高性能网络应用程序.电子工程师32 10.2006,32(10),71-73. *

Also Published As

Publication number Publication date
CN101202704A (en) 2008-06-18
WO2009030130A1 (en) 2009-03-12

Similar Documents

Publication Publication Date Title
CN101202704B (en) Method and system for transmitting data
US9537786B2 (en) Method, device, and system for information processing based on distributed buses
WO2023284699A1 (en) Protocol stack data transmission method based on linux system, and computer device and storage medium
CN102946376B (en) Method for implementing asynchronous communication
US7171464B1 (en) Method of tracing data traffic on a network
EP2899944B1 (en) Socket processing method and device and web server
CN112039722B (en) MQTT protocol simulation method and simulation equipment
CN111083168A (en) Configurable data transmission method and device of Internet of things platform gateway and gateway
US10834033B2 (en) Method and system for transferring messages between messaging systems
CN101751291A (en) Method of sharing one serial port by application programs and device
JP7221973B2 (en) System and method for providing remote support services to test equipment
KR101416280B1 (en) Event handling system and method
WO2020006902A1 (en) Batch payment method and apparatus, computer device, and storage medium
CN105871520A (en) Data transmission method and device
CN107040613A (en) A kind of message transmitting method and system
CN103338382A (en) Method and device for remotely monitoring digital television terminal and digital television system
CN105306278B (en) The system and method for PING network diagnosises is realized based on embedded Web webmaster
CN107483384B (en) Network data interaction method and device
CN113965447B (en) Online cloud diagnosis method, device, system, equipment and storage medium
CN103618716B (en) Conversation interaction method, equipment and system of terminal WAN management protocol
CN108347705B (en) CMPP short message platform and application method thereof
CN104468514B (en) Information processing method, electronic equipment and server
CN102164324A (en) Set top box and information interactive system and method of set top box
CN109992572A (en) A kind of method of adaptive equalization log storage request
EP4300306A1 (en) Streaming media processing method and apparatus based on inference service and electronic device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: SHENZHEN LONGSHI MEDIA CO., LTD.

Free format text: FORMER OWNER: SHENZHEN TONGZHOU ELECTRONIC CO., LTD.

Effective date: 20120418

C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20120418

Address after: 518057 Nanshan District hi tech park, Guangdong, North District Rainbow science and Technology Building

Patentee after: Shenzhen Longguan Media Co., Ltd.

Address before: 518057 W2-A7 building, hi tech park, Shennan Avenue, Shenzhen, Guangdong, Nanshan District

Patentee before: Shenzhen Tongzhou Electronic Co., Ltd.

ASS Succession or assignment of patent right

Owner name: SHENZHEN TONGZHOU ELECTRONIC CO., LTD.

Free format text: FORMER OWNER: SHENZHEN LONGSHI MEDIA CO., LTD.

Effective date: 20140519

C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20140519

Address after: 518057 rainbow science and Technology Building (North West Road), Nanshan District hi tech Zone, Shenzhen, Guangdong

Patentee after: Shenzhen Tongzhou Electronic Co., Ltd.

Address before: 518057 Nanshan District hi tech park, Guangdong, North District Rainbow science and Technology Building

Patentee before: Shenzhen Longguan Media Co., Ltd.

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20100818

Termination date: 20150907

EXPY Termination of patent right or utility model