Summary of the invention
In view of this, the application's technical problem to be solved has been to provide the method and system that similar networking request in a kind of mobile terminal connects communication, to solve the networking request of the same type that different application and thread are initiated in mobile terminal, cannot use unified networking port to carry out the problem that network connects communication.
In order to solve the problems of the technologies described above, the application discloses similar networking request in a kind of mobile terminal and has connected the method for communicating by letter, and comprising:
Different networking process in monitoring mobile terminal, the server being associated according to described networking process creates the local networking service matching in this mobile terminal;
Identify the access request in this mobile terminal, and start corresponding described local networking service according to the described access request with same characteristic features identifying, and generate at least one long connection request and be sent to the described server being associated with this local networking service;
At described server, respond this long connection request and set up after long connection, described access request being carried out to protocol adaptation processing and by described long connection, be sent to this server and carry out data communication.
Preferably, wherein, the server being associated according to described networking process creates the local networking service matching in this mobile terminal, is further:
The server being associated according to described networking process creates for the transmit port of setting that described mobile terminal is bound the local networking service matching in this mobile terminal;
Wherein, the server that described networking process is associated is the server that this networking process is accessed when networking.
Preferably, wherein, according to the described access request with same characteristic features identifying, start corresponding described local networking service, be further:
Identify IP address and described transmit port that whether described access request comprises described mobile terminal simultaneously, the described access request that simultaneously comprises described IP address and transmit port to identifying starts corresponding described local networking service.
Preferably, wherein, also comprise: the described access request that comprises described IP address and transmit port when identifying difference, the described transmit port starting in described mobile terminal is carried out data communication.
Preferably, wherein, also comprise:
Monitor the access request amount of described mobile terminal and in conjunction with the described long transmission capacity connecting of having set up, the quantity of this length connection controlled.
In order to solve the problems of the technologies described above, the similar networking request in a kind of mobile terminal that disclosed herein as well is connects the system of communicating by letter, and is arranged between mobile terminal and server, comprising: creating unit, identifying processing unit and transmission unit, wherein,
Described creating unit, for monitoring the different networking process of mobile terminal, the server being associated according to described networking process creates the local networking service matching in this mobile terminal;
Described identifying processing unit, for identifying the access request of this mobile terminal, and start corresponding described local networking service according to the described access request with same characteristic features identifying, and generate at least one long connection request and be sent to the described server being associated with this local networking service;
Described transmission unit, for responding this long connection request at described server and setting up after long connection, carries out protocol adaptation processing by described access request and is sent to this server and is carried out data communication by described long connection.
Preferably, wherein, described creating unit, is further used for the server that is associated according to described networking process and in this mobile terminal, creates for the transmit port of setting that described mobile terminal is bound the local networking service matching;
Wherein, the server that described networking process is associated is the server that this networking process is accessed when networking.
Preferably, wherein, described identifying processing unit, be further used for identifying IP address and the described transmit port whether described access request comprises described mobile terminal simultaneously, the described access request that simultaneously comprises described IP address and transmit port to identifying starts corresponding described local networking service.
Preferably, wherein, described identifying processing unit, the described access request for comprising described IP address and transmit port when identifying difference also, the described transmit port starting in described mobile terminal is carried out data communication.
Preferably, wherein, described transmission unit, also for monitoring the access request amount of described mobile terminal and in conjunction with the described long transmission capacity connecting of having set up, the quantity of this length connection being controlled.
Compared with prior art, in a kind of mobile terminal described in the application, similar networking request connects the method and system of communication, has reached following effect:
1) the application can will set up long connection in mobile terminal between multiple access request server associated with it, so, even different APP send to a plurality of access request of a certain server, unification is transmitted to control by local networking service, avoided to different networking ports in mobile terminal repeat call, saved the live load of mobile terminal, also reduced taking of the network bandwidth, efficiently solving the networking request of the same type that different application and thread are initiated in mobile terminal cannot use unified networking port to carry out the problem that network connects communication.
2) the long various communications protocols such as supporting HTTP, TCP, agency agreement that is connected between mobile terminal and server in the application, can reduce the number of times of shaking hands that connects while setting up (as: reducing foundation and the number of times of closing tcp and being connected) and network traffics; Meanwhile, due to the long lasting characteristic connecting, also can reduce the time delay of subsequent request.
3) the long connection that the application sets up can increase or reduce according to actual access request amount, efficiently solves and long connection by the unified communication management of terminal foundation shortage and route in the LAN environment based on route can only set up the problem of short connection.
Certainly, arbitrary product of enforcement the application must not necessarily need to reach above-described all technique effects simultaneously.
Embodiment
As used some vocabulary in the middle of specification and claim, censure specific components.Those skilled in the art should understand, and hardware manufacturer may be called same assembly with different nouns.This specification and claims are not used as distinguishing the mode of assembly with the difference of title, but the difference in function is used as the criterion of distinguishing with assembly.If " comprising " mentioned in the middle of specification and claim is in the whole text an open language, therefore should be construed to " comprise but be not limited to "." roughly " refer to that in receivable error range, those skilled in the art can solve the technical problem within the scope of certain error, reach described technique effect substantially.In addition, " couple " word and comprise directly any and electric property coupling means indirectly at this.Therefore, if describe a first device in literary composition, be coupled to one second device, represent that described first device can directly be electrically coupled to described the second device, or be indirectly electrically coupled to described the second device by other devices or the means that couple.Specification subsequent descriptions is for implementing the application's better embodiment, and right described description is to illustrate that the application's rule is object, not in order to limit the application's scope.The application's protection range is when being as the criterion depending on the claims person of defining.
Embodiment mono-
As shown in Figure 1, for similar networking request in a kind of mobile terminal described in the embodiment of the present application one connects the method for communicating by letter, the method comprises:
Step 101, different networking process in monitoring mobile terminal, the server being associated according to described networking process creates the local networking service matching in this mobile terminal.
The APP moving in mobile terminal or system (as: Android system) will be carried out network connection, to realize Data Update, synchronously wait operation, no matter be APP or operating system, conventionally all by thering is accordingly the thread of network savvy, carry out network connection, and set up network between the server that different threads can be associated to it respectively, connect, for example: certain video APP, the networking process of its generation will be accessed the server of corresponding video website, and the networking process of this video APP can not accessed other servers, namely the server of video website is associated with the networking process of current video APP.Like this, in above-mentioned steps 101, the server that just can access according to networking processes different in mobile terminal, as difference, is sorted out individual networking process, then for local networking service corresponding to each class networking process creation.
Wherein, the service layer (Service Layer) of local networking service-creation in current mobile terminal, concrete as: Backend Unify Network Layer(rear end Unified Network communication layers), after this local networking service is created at the running background of mobile terminal.
Step 102, identify the access request in this mobile terminal, according to the described access request with same characteristic features identifying, start corresponding described local networking service, and generate at least one long connection request and be sent to the described server being associated with this local networking service.
As: watch the operation indications such as one section of video, the access websites page, so, corresponding APP will initiate access request to the server being associated; In the operating system of moving in mobile terminal, also can produce access request, as: system update, this access request will send the server of acquiescence.When above-mentioned these access request generate, mobile terminal will be identified, the access request of the same server of access is identified as to same class, trigger corresponding local networking service, by host-host protocol corresponding to this local networking service-creation, as, local http protocol (Hypertext Transfer Protocol, HTML (Hypertext Markup Language)), Transmission Control Protocol (Transmission Control Protocol, transmission control protocol) etc., access request connects foundation and transfer of data by the connection protocol of above-mentioned local networking service-creation.
Here it should be noted that, in same mobile terminal, arbitrary APP or the operating system operating on this mobile terminal may be sent the access request to server at any time, so, when local networking service reception is after arbitrary access request, just set up immediately with the long of corresponding server and connect, thereby the access request of mobile terminal is sent in server in time to obtain corresponding data.
In addition, for long, connect, the access request that mobile terminal sends will be obtained dissimilar data in different server, as: obtain the data of certain webpage to show this Website page in browser; Obtain one section of video data and in terminal, cushion (or download) to play.And the transmission capacity of each long connection of setting up is limited, a plurality of access request in mobile terminal are all obtained in the situation of mass data, if only with a long connection transmission, can cause data transmission efficiency to be had a strong impact on.So in above-mentioned steps 102, at least one long connection request of generation is sent to server, to set up at least one long connection.In actual applications, the initial long quantity connecting of setting up determines the corresponding data volume of the access request of emitting according to different terminals, conventionally contains the sign of corresponding data in access request, by sign, and can know the data volume that needs transmission.
Step 102, at described server, respond this long connection request and set up after long connection, the data message that a plurality of described terminals are sent was sent to respectively in described server by described long connection, and by this long communication data that receives described server feedback that connects.
In LAN, due to the needs of each terminal communication transmission, the access request type that it sends is various: can be the connection request based on HTTP, can be also the connection request based on TCP, or the connection request based on agency agreement etc.By long connection the between router and server, the dissimilar access request that each terminal is sent all realizes communications in long connection, thereby has avoided the access request of each type to server, repeatedly to shake hands (connecting a kind of interactive mode in process of establishing) respectively.
In communication transmission process, with a long example that is connected to, in the situation that this long connection transmission capacity allows, the data message that different terminals sends will be within this length connects parallel transmission, as another kind of mode, the time sequencing of the access request that data message also can send according to different terminals is transmitted, and only, when access request amount surpasses the maximum transfer capacity of a long connection, sets up new long connection; The communication data that server feeds back will decide transmission sequence according to the processing speed of different access request, be that server is set up transmit queue, for the access request of first finishing dealing with, server preferentially connects the corresponding communication data of this access request to transmit by this length, and the corresponding communication data of other access request is arranged in order transmission according to the order of finishing dealing with.
Step 103, responds this long connection request and sets up after long connection at described server, described access request is carried out to protocol adaptation processing and by described long connection, be sent to this server and carried out data communication.
The long agreement based on fixing conventionally that connects of setting up; as: Transmission Control Protocol; and the different access request of initiating in mobile terminal may be various; based on each quasi-protocol; as: the various communications protocols such as HTTP, TCP, agency agreement; so local networking service will be carried out protocol adaptation processing to being sent to a plurality of access request of same server, to meet the long host-host protocol connecting.
By the above-mentioned steps of the present embodiment, can in mobile terminal, long connection will be set up between multiple access request server associated with it, so, even different APP send to a plurality of access request of a certain server, unification is transmitted to control by local networking service, avoided to different networking ports in mobile terminal repeat call, saved the live load of mobile terminal, also reduced taking of the network bandwidth, in addition, mobile terminal is supported HTTP with long connection the between server, TCP, the various communications protocols such as agency agreement, can reduce the number of times of shaking hands that connects while setting up (as: reduce and set up and the number of times of closing TCP and being connected) and network traffics, meanwhile, due to the long lasting characteristic connecting, also can reduce the time delay of subsequent request.
Embodiment bis-
As shown in Figure 2, for similar networking request in a kind of mobile terminal described in the embodiment of the present application two connects the method for communicating by letter, the method comprises:
Step 201, a plurality of access request based on HTTP and Transmission Control Protocol of monitoring in mobile terminal, and the server being associated according to described networking process creates for the transmit port of setting that described mobile terminal is bound the local networking service matching in this mobile terminal.
In step 201, the server that described networking process is associated is the server that this networking process is accessed when networking.
The networking process that the APP moving on mobile terminal produces, all with the set service identifiers of GaiAPP provider, in the server of Ji Gai APP provider, can identify the networking process with this service identifiers that runs on different mobile terminal, thereby, for different mobile terminal bindings, coffret is set to distinguish different mobile terminals.
Step 202, identifies the access request in this mobile terminal, identifies IP address (Internet Protocol, network interconnection agreement) and described transmit port that whether described access request comprises described mobile terminal simultaneously.
Step 203, the described access request that simultaneously comprises described IP address and transmit port to identifying starts corresponding described local networking service, and generates at least one long connection request and be sent to the described server being associated with this local networking service.
Have the IP address that matches with local networking service and the access request of transmit port, will trigger this local networking service, by local networking service, to corresponding server, set up long connection.
Step 204, the described access request that comprises described IP address and transmit port when identifying difference, the described transmit port starting in described mobile terminal is carried out data communication.
Step 205, responds this long connection request and sets up after long connection at described server, described access request is carried out to protocol adaptation processing and by described long connection, be sent to this server and carried out data communication.
Protocol adaptation is processed the corresponding data of access request that make based on different agreement and can in same long connection, be transmitted, under a kind of mode in the present embodiment, the access request of the different agreement that each terminal is sent (as: the long connection of HTTP, the short connection of HTTP, SPDY agreement and raw tcp protocol etc.) no matter, all transmission in long connection of setting up based on Transmission Control Protocol, just in the long connection of TCP, different agreement is arranged to different passages, thereby the corresponding data of access request of multi-protocols just can be transmitted in transmission channel separately.
In addition, in the present embodiment, the access request of sending in mobile terminal has randomness, may appear at sometime that section is carried out a large amount of access request or in section sometime without the situation of any access request.For mobile terminal, sending the situation of a large amount of access request sometime in section, initial long connection of setting up is not enough to all access request to transmit in the lump, so in order not delay transmission progress, will increase the long quantity connecting of TCP; For mobile terminal in section sometime without the situation of any access request (as in the night, terminal is not all worked), if also continue to keep many long connections, will inevitably waste the network bandwidth so, also increase the live load of router, so by reducing the long quantity connecting, disconnect long connection even completely.
Embodiment tri-
Below in conjunction with Fig. 3, the concrete application that similar networking request in described mobile terminal is connected to the method for communication is elaborated:
In mobile terminal, include a plurality of APP such as functional unit 1, functional unit 2, functional unit 3, functional unit 4 and third party's assembly 1, third party's assembly 2, and set up and being connected of cloud server by web services layer, wherein, web services layer can be specifically the background service program of this mobile terminal, for example the local networking service in above-described embodiment one and two.
A plurality of APP send respectively dissimilar access request: the access request of functional unit 1 is that the access request of the short connection request of HTTP, functional unit 2 is that the access request of the long connection request of HTTP, functional unit 3 is that the access request of SPDY agreement request, functional unit 4 is that the access request of TCP connection request, third party's assembly 1 is that the access request of agency agreement request, third party's assembly 2 is the connection protocol request based on TCP.Above-mentioned request manages control by corresponding local networking service, and be connected with the long of cloud server by local networking service foundation, length in the present embodiment is connected to the long connection of TCP, so, local networking service is carried out protocol adaptation processing by the different access request that the different terminals receiving is sent, transmission in connecting so that the TCP current is long.
The long quantity connecting of TCP can determine according to the corresponding data volume of access request, also can arrange in advance, as: every 2 access request share a long connection.Under a kind of optimal way, local networking service can be monitored the access request amount of mobile terminal, so that the long quantity connecting is controlled: comprise in 30 minutes and will reclaim gradually the long connection of idle TCP.
Here it should be noted that, because different local networking service meetings is set up long connection to different server (being different APP servers), so, in the present embodiment, initial long connection of setting up just may be many, the long quantity connecting of TCP is controlled described in foregoing is for long connection of setting up with a certain server.
IP address and transmit port that web services layer comprises in will the different access request of monitoring, only have when IP address and transmit port are all mated, and just can start corresponding local networking service, by local networking service, is sent to corresponding server.Cloud server will carry out protocol analysis after receiving respectively the access request simultaneously with IP address and transmit port, to resolving the different access request obtaining, process afterwards, because different access request is accessed the data difference of obtaining, as: only obtain the displaying contents of Website page and obtain one section of video data, therefore server is not identical to the processing speed of different access request yet, the corresponding data of access request that server completes priority treatment are connected and are fed back in corresponding local networking service by length, then feed back on corresponding APP.
Take arbitrary APP as example, after mobile terminal is installed this APP, will move a background service and open a random port simultaneously, to the service of this APP, provide unified networking Request Control.The address of the local networking service of mobile terminal inside is: localhost:port, the long connection of http://localhost:port form of its support function assembly 1; The short connection of http://localhost:port form of support function assembly 2; The HTML5 WebSocket communication (ws: //localhost:port form) of support function assembly 3; The TCP SOCKET passage (localhost:port form) of support function assembly 4; Some common agreements that support builds based on TCP, such as (spdy: //localhost:port form) such as SPDY.
In addition, local networking service can be encrypted, compress processing to different access request, has not only strengthened the fail safe of transfer of data, has also increased the transmission characteristic of data.
Embodiment tetra-
As shown in Figure 4, for similar networking request in a kind of mobile terminal described in the embodiment of the present application four connects the system of communicating by letter, be arranged between mobile terminal and server, this system comprises: creating unit 401, identifying processing unit 402 and transmission unit 403, wherein:
Described creating unit 401, couples mutually with identifying processing unit 402, and for monitoring the different networking process of mobile terminal, the server being associated according to described networking process creates the local networking service matching in this mobile terminal.
Described identifying processing unit 402, couple mutually with mobile terminal, creating unit 401 and server respectively, for identifying the access request of this mobile terminal, and start corresponding described local networking service according to the described access request with same characteristic features identifying, and generate at least one long connection request and be sent to the described server being associated with this local networking service.
Described transmission unit 403, couple mutually with mobile terminal and server respectively, for responding this long connection request at described server and setting up after long connection, described access request is carried out to protocol adaptation processing and by described long connection, be sent to this server and carry out data communication.
The access request that different terminals sends will be obtained dissimilar data in server, as: obtain the data of certain webpage to show this Website page in browser; Obtain one section of video data and in terminal, cushion (or download) to play.And the transmission capacity of each long connection of setting up is limited, in the situation that a plurality of terminals in LAN are all obtained mass data, if only with a long connection transmission, can cause data transmission efficiency to be had a strong impact on.
Described creating unit 401 creates for the transmit port of setting that described mobile terminal is bound the local networking service matching specifically for the server that is associated according to described networking process in this mobile terminal.Wherein, the server that described networking process is associated is the server that this networking process is accessed when networking.
The networking process that the APP moving on mobile terminal produces, all with the set service identifiers of GaiAPP provider, in the server of Ji Gai APP provider, can identify the networking process with this service identifiers that runs on different mobile terminal, thereby, for different mobile terminal bindings, coffret is set to distinguish different mobile terminals, and have the IP address that matches with local networking service and the access request of transmit port, to trigger this local networking service, by local networking service, to corresponding server, set up long connection, therefore, described identifying processing unit 402, the IP address and the described transmit port that specifically for identifying described access request, whether comprise described mobile terminal simultaneously, the described access request that simultaneously comprises described IP address and transmit port to identifying starts corresponding described local networking service, and, the described access request that comprises described IP address and transmit port when identifying difference, the described transmit port starting in described mobile terminal is carried out data communication.
The access request of sending in mobile terminal has randomness, may appear at sometime that section is carried out a large amount of access request or in section sometime without the situation of any access request.For mobile terminal, sending the situation of a large amount of access request sometime in section, initial long connection of setting up is not enough to all access request to transmit in the lump, so in order not delay transmission progress, by the long quantity connecting; For mobile terminal in section sometime without the situation of any access request (as in the night, terminal is not all worked), if also continue to keep many long connections, will inevitably waste the network bandwidth so, also increase the live load of router, so by reducing the long quantity connecting, disconnect long connection even completely.So in the present embodiment, described transmission unit 403, also for monitoring the access request amount of described mobile terminal and in conjunction with the described long transmission capacity connecting of having set up, the quantity of this length connection being controlled.
Because method part have been described in detail the embodiment of the present application, here the expansion of the System and method for corresponding part relating in embodiment is described and omitted, repeat no more.The reference method embodiment of content can to(for) the description of particular content in system, no longer specifically limits here.
Compared with prior art, in a kind of mobile terminal described in the application, similar networking request connects the method and system of communication, has reached following effect:
1) the application can will set up long connection in mobile terminal between multiple access request server associated with it, so, even different APP send to a plurality of access request of a certain server, unification is transmitted to control by local networking service, avoided to different networking ports in mobile terminal repeat call, saved the live load of mobile terminal, also reduced taking of the network bandwidth, efficiently solving the networking request of the same type that different application and thread are initiated in mobile terminal cannot use unified networking port to carry out the problem that network connects communication.
2) the long various communications protocols such as supporting HTTP, TCP, agency agreement that is connected between mobile terminal and server in the application, can reduce the number of times of shaking hands that connects while setting up (as: reducing foundation and the number of times of closing tcp and being connected) and network traffics; Meanwhile, due to the long lasting characteristic connecting, also can reduce the time delay of subsequent request.
3) the long connection that the application sets up can increase or reduce according to actual access request amount, efficiently solves and long connection by the unified communication management of terminal foundation shortage and route in the LAN environment based on route can only set up the problem of short connection.
Also it should be noted that, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby the process, method, commodity or the system that make to comprise a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or be also included as the intrinsic key element of this process, method, commodity or system.The in the situation that of more restrictions not, the key element being limited by statement " comprising ... ", and be not precluded within process, method, commodity or the system that comprises described key element and also have other identical element.
The embodiment that it will be understood by those skilled in the art that the application can be provided as method, system or computer program.Therefore, the application can adopt complete hardware implementation example, implement software example or in conjunction with the form of the embodiment of software and hardware aspect completely.And the application can adopt the form that wherein includes the upper computer program of implementing of computer-usable storage medium (including but not limited to magnetic disc store, CD-ROM, optical memory etc.) of computer usable program code one or more.
The embodiment that the foregoing is only the application, is not limited to the application.To those skilled in the art, the application can have various modifications and variations.Any modification of doing within all spirit in the application and principle, be equal to replacement, improvement etc., within all should being included in the application's claim scope.