Establish the method, apparatus and system of long connectionTechnical field
The present invention relates to a kind of Internet technical fields, more particularly to a kind of method, apparatus for establishing long connection and areSystem.
Background technique
In LAN environment, is typically set up between server and terminal and keep transmission control protocol(Transmission Control Protocol, TCP) long connection, it can be ensured that server is timely by mission dispatching to eventuallyEnd, terminal receive and respond the task.
But in actual scene, server can't issue assignment instructions to terminal in real time, in the most of the time, TCPLong connection is at idle state, occupies valuable network transmission resource.For larger local area network, buildIt stands and keeps thousands of TCP long connections that can cause biggish load pressure to network, may result under extreme case wholeThe paralysis of a local area network.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method, apparatus and system for establishing long connection, main purpose isSolve the problems, such as that long connection occupies Internet resources.
According to the present invention on one side, a kind of method for establishing long connection is provided, comprising:
Long connection is established with terminal;
Assignment instructions are issued to terminal by long connection, so that terminal executes corresponding task according to assignment instructions;
After terminal has executed task, the long connection established with terminal is disconnected.
According to another aspect of the present invention, the device for establishing long connection is provided, comprising:
Unit is established, for establishing long connection with terminal;
Issuance unit issues assignment instructions to terminal for the long connection by establishing unit foundation, so as to terminal according toAssignment instructions execute corresponding task;
Switching units, for after the task that terminal has executed that issuance unit issues, disconnecting the long connection established with terminal.
According to another aspect of the present invention, the system for establishing long connection, including terminal and server are provided, wherein eventuallyEnd includes device as described above.
By above-mentioned technical proposal, the method, apparatus and system provided by the invention for establishing connection is based on server and endThe long connection that end is established, server are connected to terminal by the length and issue assignment instructions, and terminal receives the assignment instructions and basisThe assignment instructions go to execute corresponding task, disconnect the long connection established with server after having executed task.With prior art phaseThan in the present invention, terminal can select the best opportunity for establishing long connection with server according to the demand of itself, and can be withAfter the task that terminal has executed that server issues, the long connection established with server is interrupted, this kind of mode reduces serverThe Internet resources occupied when long connection are always maintained at terminal.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention,And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage canIt is clearer and more comprehensible, the followings are specific embodiments of the present invention.
Detailed description of the invention
By reading the following detailed description of the preferred embodiment, various other advantages and benefits are common for this fieldTechnical staff will become clear.The drawings are only for the purpose of illustrating a preferred embodiment, and is not considered as to the present inventionLimitation.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 shows a kind of flow chart of method for establishing long connection provided in an embodiment of the present invention;
Fig. 2 shows a kind of composition block diagrams for the device for establishing long connection provided in an embodiment of the present invention;
Fig. 3 shows a kind of composition block diagram of system for establishing long connection provided in an embodiment of the present invention.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawingExemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth hereIt is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosureIt is fully disclosed to those skilled in the art.
The embodiment of the invention provides a kind of method, apparatus and system for establishing long connection, as shown in Figure 1, this method packetIt includes:
101, long connection is established with terminal.
During the actual network operation, terminal needs to send the solicited message for establishing short connection, service to serverAfter device receives the solicited message, determine that establishing network communication with terminal connect.It establishes after network communication connection, serverIt is communicated with terminal, in communication process, when server discovery has data packet to need to be handed down to terminal, server can be to endEnd sends the instruction information for establishing long connection, after the instruction information for the long connection of foundation that terminal receives server transmission, eventuallyThe solicited message for sending to server and establishing long connection is held, establishes long connection with service.In the embodiment of the present invention, server and endIt is unimpeded that the long connection that end is established can not only maintain the network communication between server and terminal connect, but also work as and have data packetWhen needing to issue, server can be connected to terminal based on the length and issue data packet in time.
Optionally, can also be before terminal and server carry out network communication connection, terminal to server is directThe solicited message for establishing long connection is sent, it is determining to establish long connection with terminal after server receives the solicited message.AboutServer and terminal establish the realization process of long connection, and it is not limited by the embodiments of the present invention.
102, assignment instructions are issued to terminal by long connection, so that terminal executes corresponding task according to assignment instructions.
After above-mentioned steps 101 and terminal establish long connection, server can be connected to terminal by the length and issue taskInstruction parses the assignment instructions after terminal receives assignment instructions, obtains the task that simultaneously execute server issues.Wherein,Carry system or application program updating in assignment instructions, patch reparation updates, unloading etc., about carrying in assignment instructionsThe contents of specific tasks set according to the actual situation, the specific embodiment of the present invention is to this without limiting.
When server, which has new assignment instructions to need to be handed down to terminal, to be executed, server not necessarily immediately will be newAssignment instructions are handed down to terminal, after server can also be obtained other a part of new task instructions after a period of time, then will obtainThe assignment instructions taken are handed down to terminal, so that carrying more assignment instructions for being directed to different task in assignment instructions.ThisIn inventive embodiments, when server to terminal issue assignment instructions be it is multiple when, can first to terminal send multiple tasks instructionOne of assignment instructions issue other assignment instructions to terminal again after waiting terminal to respond the assignment instructions;OrIt is all sent to terminal using by the multiple tasks instruction of server end, which terminal responds according to the demand of itself selection firstAssignment instructions.Specifically issuing the modes of assignment instructions to terminal about server, it is not limited by the embodiments of the present invention.
Optionally, terminal parses assignment instructions, can by but be not limited to mode below and realize, for example,Terminal parses the content carried in assignment instructions one by one, after obtaining all tasks carried in the assignment instructions, eventuallyEnd is gone to execute all tasks obtained again;Alternatively, the content that terminal carries assignment instructions parses, assignment instructions are parsedIn entrained one of task, and the task is executed, after having executed the task, entrained by continuing to parse in assignment instructionsOther tasks, repeatedly, until having parsed all tasks carried in assignment instructions.Wherein, about logical to taskThe resolving of instruction, it is not limited by the embodiments of the present invention.
103, after terminal has executed task, the long connection established with terminal is disconnected.
After terminal has executed corresponding task according to assignment instructions, being not carried out for task is checked for, if it exists notThe task of execution then continues to execute the task that server issues;Being not carried out if it does not exist for task is then disconnected and being established with serverLong connection.In this step, in order to reduce the occupancy of Internet resources, while the assignment instructions usual situation that server issuesUnder be it is disposable effective, terminal disconnects the long connection established with server after having executed the task that server issues.
The method provided in an embodiment of the present invention for establishing connection, based on the long connection that server and terminal are established, serverIt is connected by the length to terminal and issues assignment instructions, terminal receives the assignment instructions and goes to execute according to the assignment instructions correspondingTask disconnects the long connection established with server after having executed task.Compared with prior art, in the present invention, terminal can rootThe best opportunity of long connection is established with server according to the demand selection of itself, and server can also have been executed in terminal and issuedTask after, interrupt with server establish it is long connect, this kind of mode reduces server and when terminal is always maintained at long connectionThe Internet resources of occupancy.
In the implementation process that step 101 and terminal establish long connection, long connection is kept to occupy in order to further reduceInternet resources disconnect the short connection established with terminal in time after server and terminal establish long connection;It has been executed in terminalAfter the task that server issues, the long connection established with server is disconnected, and establish asking for short connection to server transmission againAfter asking information, server to receive the solicited message, determine that establishing network communication with terminal connect.Wherein, terminal again withThe purpose that server establishes short connection is that the synchronism of holding server and terminal data, terminal can be sent out to server timingHeartbeat message is sent, to determine when server has task to issue to terminal, server can send in time to terminal and establish long connectThe instruction information connect.Wherein, the period that terminal to server regularly sends heartbeat message is rule of thumb set, for example, canSetting terminal sent a heartbeat message to server every 5 seconds, can also be sent out every 10 seconds to server with setting terminalA heartbeat message is sent, to ensure the synchronism of data between terminal and server.Specifically the heart is sent about terminal to serverThe period of message is jumped, it is not limited by the embodiments of the present invention.
In another embodiment of the present invention, when terminal and server establish long connection, when needing to select suitableMachine, it is ensured that the Internet resources for maintaining long connection to occupy should be reduced, ensure that the task of server end can be handed down in time againTerminal.Wherein, the opportunity that selection terminal and server establish long connection can be by different modes, below by following seven kinds of sidesFormula describes in detail:
Mode one:
Timing establishes long connection with terminal.
Timing mentioned here and terminal establish long connection should be establish network communication connection in terminal and server, andIt keeps realizing on the basis of terminal and server data are synchronous.Illustratively, after setting timing establishes long connection with terminal, clothesBusiness device can establish long connection according to the timing cycle pre-set with terminal automatically, and after establishing long connection, server can be examinedLooking into its own whether there is the assignment instructions for needing terminal to execute;If it exists, then it is connected based on the length and issues task to terminal and refer toIt enables.Wherein, the period of the timing is rule of thumb, is manually set, for example, the period of setting timing be half an hour, it is one smallWhen;Alternatively, the period that timing can be set is ten minutes, 20 minutes.The period embodiment of the present invention of specific setting timingTo this without setting.
Optionally, it also can choose idle period and terminal establish long connection, which refers to terminal in no netIn the idle period of network access or terminal is in its local idle period without carrying out various operations.When server and terminal are builtVertical long connection, while when server issues assignment instructions to terminal, terminal receives the assignment instructions that server issues, and in the spare timeThe task execution carried in assignment instructions is finished in period, without the Internet resources of the non-idle times of occupied terminal.Illustratively, it is generally the case that terminal user may select to rest within the 12:00-13:00 period, claim the 12:00-13:00 period was idle period, and the period in addition to 12:00-13:00 is referred to as non-idle times;Server can be selected in the skyIdle section and terminal establish long connection, and issue to the terminal in idle period about system or application program updating, mendFourth reparation, the assignment instructions updated etc., terminal execute corresponding task.Above-mentioned idle period is in addition to including 12:00-13:00It can also include 16:00-16:30 outside period, which is artificially arranged, and the specific embodiment of the present invention is to thisIt is not limited.
Illustratively, timing and terminal can also be established long connection, selection idle period and terminal by the embodiment of the present inventionThe two ways for establishing long connection is combined, i.e., other than server selection idle period and terminal establish long connection,His non-idle times are in such a way that timing establishes long connection with terminal.For example, terminal starts to establish with server in 09:00Network communication connection, the period that the timing of setting server establishes long connection with terminal is 30 minutes, when 12:00-13:00 is idleSection;After first time determining terminal and the long connection of server foundation, server can check that its own whether there is and terminal is needed to holdCapable assignment instructions, and if it exists, then connected based on the length to terminal and issue assignment instructions.According to the timing week pre-setPhase establishes long connection with terminal, repeatedly, until the period of timing is in the idle period 12:00-13:00 set,The idle period server and terminal establish long connection;Server can be since 13:00, according to preset timing weekPhase establishes long connection with terminal.The exemplary only citing of the setting of above-mentioned timing cycle and idle period, the embodiment of the present inventionThis is not limited.
Mode two:
When current network transmission condition is better than pre- age threshold, long connection is established with terminal.
Pre- age threshold mentioned here is rule of thumb, is manually set, and the purpose that pre- age threshold is arranged is to preventOnly in the case where the network transfer speeds of server and terminal are excessively slow, continues to establish server and the long of terminal connects, thusIncrease the load pressure of server or terminal.Wherein, it is 600K/s that pre- age threshold, which can be set, in the embodiment of the present invention, can alsoPre- age threshold is arranged as 400K/s.It is specific that it is not limited by the embodiments of the present invention.
Mode three:
When there is mission dispatching, long connection is established with terminal.
In the prior art, server can't issue assignment instructions to terminal in real time, server and end in the most of the timeThe long connection that end is established is at idle state, occupies more network transmission resource.Network money is occupied in order to solve long connectionThe problem of source, the embodiment of the present invention are used when there is mission dispatching, establish long connection with terminal.For example, carrying out the whole network killingVirus or when the whole network vulnerability scanning, server can by mission dispatching to terminal, enable the terminal to timely killing virus orPatching bugs.
Mode four:
The long connection of foundation according to the control of network management personnel, with terminal.
Under LAN environment, the network management personnel are to have permission the server or certain terminal that manage each terminal,Wherein, above-mentioned to have permission that manage the server of each terminal be any one server in LAN environment;It is above-mentioned certainPlatform terminal can be controlled by operator, alternatively, can also be configured to the terminal, it is arranged with terminal and establishes long connectionTime or period, duration etc. are realized and automatically control.
It will be below certain terminal to the network management personnel, and the terminal as network management personnel can be controlled by operatorThe case where processed, is described in detail, for example, server is first when server has the task of patch upgrading to need to be handed down to terminalIt is first communicated with the terminal as network management personnel, which can check terminal, and selectTerminal allows server and terminal to establish long connection in the period of less access network, wherein the terminal as network management personnel is selectedTerminal is selected in the period of less access network, needs to be selected according to the actual conditions of every terminal, the embodiment of the present inventionTo selection terminal in the less specific period for accessing network without limiting.
Mode five:
The resource occupation information of itself is issued, to terminal so that long company is stated in the server foundation of terminal selection idle stateIt connects.
In which, a communication server can be arranged in server end, which is used to count shared by terminalTerminal, terminal are handed down to before server and terminal establish long connection with the information of each server resource, and by the informationThe information issued according to communication server, the server for selecting and being in idle condition establish long connection.Illustratively, it is servicingDevice end, have a communication server, server 1, server 2, server 3 ... server end server absolutely not withResource occupation when terminal carries out network communication connection is 0, and the terminal of communication server statistics occupies the information of server resourceAs follows: communication server is occupied by 5 terminals, resource occupation 15%, and server 1 is occupied by 20 terminals, and resource occupation is60%, server 2 is occupied by 1 terminal, resource occupation 1%, and server 3 is occupied by 25 terminals, and resource occupation isInformation after statistics is sent to terminal by 62% ... the communication server, it is generally the case that in order to faster respond serviceThe task that device issues, terminal can select to establish long connection with the less server of resource occupation, above-mentioned Communications service phase statisticsIn information, the percentage of resource occupation is bigger, indicates that server is busier.Wherein, above-mentioned communication server can be established with terminalLong connection, while being used to the information of each server resource occupied by terminal;Alternatively, can also only be used to count occupied by terminalThe information of each server resource, without as the server for establishing long connection with terminal, the specific embodiment of the present invention pairThis is not limited.
Mode six:
The resource occupation information for obtaining terminal selects the terminal of idle state to establish long connection according to resource occupation information.
As also mentioned previously, the purpose that terminal and server establishes short connection is to keep the synchronism of data.It is protectingHold server it is synchronous with terminal data while server can obtain occupied information in terminal, resource occupation information in the terminalResource, the terminal operation external storage of the resource, terminal operation local application occupancy that occupy including terminal access network are setThe standby resource etc. occupied after server obtains the resource occupation information of terminal, selects the lesser terminal of resource occupation to establish lengthConnection.
Illustratively, a server establishes network communication and connect with terminal 1, terminal 2, terminal 3, has in the serverWhen task needs to issue, terminal 1, terminal 2, the resource occupation information of terminal 3, the resource for the terminal which obtains first are obtainedOccupied information is as follows: terminal 1 accesses the resource that the resource that network occupies is 2%, terminal operation local application occupies and is10%, the resource 30% that terminal operation External memory equipment occupies, it is that 50%, terminal is grasped that terminal 2, which accesses the resource that network occupies,The resource for making local application occupancy is the resource 6% of 1%, terminal operation External memory equipment occupancy, and terminal 3 accesses networkThe resource that the resource of occupancy is 1%, terminal operation local application occupies is 4%, terminal operation External memory equipment occupiesResource 8%;The resource occupation information for every terminal that server will acquire carries out additional calculation, selects smaller with resource occupationTerminal establish long connection.Wherein, resource occupation not only includes the resource of terminal access network occupancy, terminal in the terminalResource, the resource of terminal operation External memory equipment occupancy that local application occupies are operated, can also include different terminalsBetween carry out Bluetooth wireless transmission etc., the specific embodiment of the present invention is not limited.
Above-mentioned example is to establish network communication with more terminals with a server to connect, and obtain the money of the more terminalsThe explanation carried out for the occupied information of source is similarly established network communication with more terminals for multiple servers and is connect, and obtainFor the resource occupation information of corresponding more terminals, it can be every server and obtain respectively and establish network communication with its ownThe resource occupation information of the terminal of connection, and the resource occupation information that will acquire carries out add operation, every server selection withThe corresponding lesser terminal of resource occupation establishes long connection, wherein the resource occupation of counterpart terminal is obtained about multiple serversThe description of information, please refers to above-mentioned related description, and the embodiment of the present invention is no longer repeated herein.
Mode seven:
The resource occupation state of itself is monitored, when resource occupation state reaches load threshold condition, to otherThe long connection in server transfer part.
There can be a variety of situations when terminal and server establish long connection, for example, a server is built with more terminalsVertical long connection a, alternatively, server and a terminal establish long connection etc..It establishes and grows with more terminals when a serverWhen connection, it is understood that there may be the server more terminals or since terminal is more than to the access of the server compared with slow-responseThe load of the server causes the server not respond the more terminals etc..Therefore, in order to ensure server can be timelyThe terminal of long connection is established in response therewith, and the mode that server detects the resource occupation state of its own works as serverIn resource occupation state when reaching load threshold condition, can connect to other server transfer parts are long, can so dropThe load pressure of the low server reduces the expense of Internet resources, wherein the load threshold condition is rule of thumb, artificiallySetting.For example, server 1 and 5 terminal establishes long connection, server 2 and 1 terminal establishes long connection, server 3Long connection is established with 0 terminal, server 4 and 2 terminal establishes long connection, and the load thresholding of resource occupation state is arrangedCondition is that every server can only at most establish long connection with 4 terminals, and above-mentioned server can resource occupation shape to its ownState is monitored, once reaching load threshold condition, what which can be intelligent connects to other server transfer parts are long, reallyThe terminal for continuing to establish long connection therewith can timely be responded by protecting the server.
Further, it as the refinement and extension to above-described embodiment, has been executed times executing above-mentioned steps 103 in terminalAfter business, preset duration is waited, if not issuing new assignment instructions in waiting process, the length established with terminal is disconnected and connects,In, which rule of thumb, is artificially arranged.Illustratively, it is 2 minutes that setting, which waits preset duration, terminalAfter having executed the task that server issues, the long connection established with server will not be disconnected immediately, but in the waiting of settingServer is checked in preset duration, and whether there is also newly issuing for tasks, if the time that terminal waits has been more than when waiting defaultIt is long, and server does not issue task also, then the long connection that disconnected end and server are established.It is designed in this way, prevents in terminalAfter having executed a subtask, the long connection that disconnected end and server are established immediately, but server is there is also needs and at presentThe task of hair.If within a short period of time, server issues the instruction information for establishing long connection to terminal again, terminal receives this and refers toAfter showing information, long connection is established with the server, in this way, considerably increasing the expense of server network process resource.It increasesThe load of server process resource.It is 2 minutes that the embodiment of the present invention, which can be set and wait preset duration, and it is pre- that waiting also can be setIf when it is 5 minutes a length of, the specific present invention implements to be not limited.
In implementation process, above-mentioned long connection can be TCP connection, or hypertext transfer protocol (HTTP-Hypertext transfer protocol, HTTP) length connection.Specifically, it is not limited by the embodiments of the present invention.
It, can also be by it should be noted that terminal and server after establishing long connection, can be disconnected long connection by terminalServer disconnects long connection.Specifically, the embodiment of the present invention is not limited.
Further, as an implementation of the above method, the embodiment of the present invention also provides a kind of dress for establishing long connectionIt sets, as shown in Fig. 2, the device includes:
Unit 21 is established, for establishing long connection with terminal, terminal needs to send the request for establishing short connection to serverInformation after server receives the solicited message, determines that establishing network communication with terminal connect.It establishes network communication and connects itAfterwards, server is communicated with terminal, in communication process, when server discovery has data packet to need to be handed down to terminal, and clothesBusiness device can send the instruction information for establishing long connection to terminal, receive the instruction for the long connection of foundation that server is sent in terminalAfter information, terminal to server sends the solicited message for establishing long connection, establishes long connection with service;
Issuance unit 22 issues assignment instructions to terminal for the long connection by establishing the foundation of unit 21, so as to terminalCorresponding task is executed according to assignment instructions, server can be connected to terminal by the length and issue assignment instructions, and terminal, which receives, appointsAfter business instruction, which is parsed, obtains the task that simultaneously execute server issues;
Switching units 23, for disconnecting the length established with terminal after the task that terminal has executed that issuance unit 22 issuesConnection, after terminal has executed corresponding task according to assignment instructions, checks for being not carried out for task, is not carried out if it existsTask, then continue to execute the task that server issues;Being not carried out if it does not exist for task then disconnects the length established with serverConnection.
Further, in the long connection procedure for keeping establishing the foundation of unit 21, the short connection established with terminal is disconnected, isIt is further to reduce the Internet resources for keeping long connection to occupy, after server and terminal establish long connection, disconnect in time withThe short connection that terminal is established.
Further, it in the long connection procedure for keeping establishing the foundation of unit 21, is connected when disconnecting with the long of terminal foundationWhen, short connection is established with terminal, after the task that terminal has executed that server issues, disconnects the long connection established with server,And the solicited message for establishing short connection is sent to server again, and after server receives the solicited message, determining and terminalEstablish network communication connection.
Further, it establishes unit 21 to be also used to, long connection is periodically established with terminal, timing mentioned here is built with terminalVertical long connection should establish network communication connection, and the basis for keeping terminal and server data synchronous in terminal and serverUpper realization.
Further, it establishes unit 21 to be also used to, idle period and terminal is selected to establish long connection, which refers toTerminal is in the idle period that no network accesses or terminal is in its local idle period without carrying out various operations.Work as clothesDevice and the terminal of being engaged in establish long connection, while when server issues assignment instructions to terminal, terminal receives the task that server issuesInstruction, and finishes the task execution carried in assignment instructions in the idle section, without occupied terminal it is busy whenThe Internet resources of section.
Further, it establishes unit 21 to be also used to, when current network transmission condition is better than pre- age threshold, with terminalLong connection is established, pre- age threshold mentioned here is rule of thumb, is manually set, and the purpose that pre- age threshold is arranged isIt prevents in the case where the network transfer speeds of server and terminal are excessively slow, continues to establish server and the long of terminal connects, fromAnd increase the load pressure of server or terminal.
Further, it establishes unit 21 to be also used to when there is mission dispatching, establishes long connection with terminal, it is existing in order to solveServer will not issue assignment instructions to terminal in real time in technology, and the long connection that server and terminal are established in the most of the time is allThe problem of being in idle state, occupying more network transmission resource, the embodiment of the present invention is used when there is mission dispatching, with endLong connection is established at end.
Further, it establishes unit 21 to be also used to, according to the control of network management personnel, be connected with the foundation length of terminal, in officeUnder the net environment of domain, the network management personnel are to have permission the server or certain terminal that manage each terminal, wherein above-mentioned to have the rightThe server that limit manages each terminal can be any one server in LAN environment;Above-mentioned certain terminal can be by graspingMake personnel control, alternatively, can also be configured to the terminal, be arranged its time that long connection is established with terminal or period,Duration etc. is realized and is automatically controlled.
Further, it establishes unit 21 to be also used to, the resource occupation information of itself is issued to terminal, so that terminal selects skyThe server of not busy state establishes long connection, and a communication server can be arranged in server end, which is used to count eventuallyThe information of occupied each server resource is held, and the information is handed down to end before server and terminal establish long connectionEnd, the information that terminal is issued according to communication server, the server for selecting and being in idle condition establish long connection.
Further, unit 21 is established to be also used to:
The resource occupation information for obtaining terminal selects the terminal of idle state to establish long connection according to resource occupation information,The purpose that terminal and server establishes short connection is to keep the synchronism of data.Keeping server synchronous with terminal dataServer can obtain occupied information in terminal simultaneously, and resource occupation information includes the money that terminal access network occupies in the terminalThe resource etc. that source, the resource of terminal operation local application occupancy, terminal operation External memory equipment occupy, server obtainsAfter taking the resource occupation information of terminal, the lesser terminal of resource occupation is selected to establish long connection.
Further, it establishes unit 21 to be also used to, the resource occupation state of itself is monitored;
When resource occupation state reaches load threshold condition, connected to other server transfer parts are long, terminal withServer can have a variety of situations when establishing long connection, for example, a server establishes long connection with more terminals, alternatively, onePlatform server and a terminal establish long connection etc..When a server establishes long connection with more terminals, it is understood that there may beThe server more terminals or since terminal has been more than the load of the server to the access of the server compared with slow-response,The server is caused not respond the more terminals etc..Therefore, in order to ensure server can timely respond to establish length therewithThe terminal of connection, the mode that server detects the resource occupation state of its own, when the resource occupation shape in serverWhen state reaches load threshold condition, it can be connected to other server transfer parts are long, can so reduce the negative of the serverLotus pressure reduces the expense of Internet resources, wherein the load threshold condition is rule of thumb, is manually set.
Further, switching units 23 are also used to:
After terminal has executed task, preset duration is waited to disconnect if not issuing new assignment instructions in waiting processThe long connection established with terminal, wherein the waiting preset duration rule of thumb, is artificially arranged.Illustratively, setting waitsPreset duration is 2 minutes, and terminal will not disconnect the long company established with server after having executed the task that server issues immediatelyConnect, but checked in the waiting preset duration of setting server whether there is also newly issuing for task, if terminal wait whenBetween be more than waiting preset duration, and server does not issue task also, then what disconnected end and server were established long connects.
Further, length is connected as TCP connection.
Further, as an implementation of the above method and the application of above-mentioned apparatus, the embodiment of the present invention also provide oneThe system that kind establishes long connection, as shown in figure 3, the system includes: terminal 31 and server 32, wherein server 32 includes upperState Fig. 2 shown device.
The long connection that the apparatus and system provided in an embodiment of the present invention for establishing connection is established based on server and terminal, clothesBusiness device is connected to terminal by the length and issues assignment instructions, and terminal receives the assignment instructions and goes execution pair according to the assignment instructionsAnswering for task disconnects the long connection established with server after having executed task.Compared with prior art, in the present invention, terminal canTo establish the best opportunity of long connection with server according to the demand of itself selection, and server can also have been executed in terminalAfter issuing for task, the long connection established with server is interrupted, this kind of mode reduces server and terminal is always maintained at long companyThe Internet resources occupied when connecing.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodimentPoint, reference can be made to the related descriptions of other embodiments.
It is understood that the correlated characteristic in the above method and device can be referred to mutually.In addition, in above-described embodiment" first ", " second " etc. be and not represent the superiority and inferiority of each embodiment for distinguishing each embodiment.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
Algorithm and display are not inherently related to any particular computer, virtual system, or other device provided herein.Various general-purpose systems can also be used together with teachings based herein.As described above, it constructs required by this kind of systemStructure be obvious.In addition, the present invention is also not directed to any particular programming language.It should be understood that can use variousProgramming language realizes summary of the invention described herein, and the description done above to language-specific is to disclose this hairBright preferred forms.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the inventionExample can be practiced without these specific details.In some instances, well known method, structure is not been shown in detailAnd technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of the various inventive aspects,Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimesIn example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protectShield the present invention claims features more more than feature expressly recited in each claim.More precisely, as followingClaims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore,Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itselfAll as a separate embodiment of the present invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodimentChange and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodimentMember or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement orSub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use anyCombination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosedAll process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint powerBenefit require, abstract and attached drawing) disclosed in each feature can carry out generation with an alternative feature that provides the same, equivalent, or similar purposeIt replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodimentsIn included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the inventionWithin the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointedMeaning one of can in any combination mode come using.
Various component embodiments of the invention can be implemented in hardware, or to run on one or more processorsSoftware module realize, or be implemented in a combination thereof.It will be understood by those of skill in the art that can be used in practiceMicroprocessor or digital signal processor (DSP) are some or complete in denomination of invention according to an embodiment of the present invention to realizeThe some or all functions of portion's component.The present invention be also implemented as a part for executing method as described herein orThe device or device program (for example, computer program and computer program product) of person's whole.Such realization is of the inventionProgram can store on a computer-readable medium, or may be in the form of one or more signals.Such signalIt can be downloaded from an internet website to obtain, be perhaps provided on the carrier signal or be provided in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and abilityField technique personnel can be designed alternative embodiment without departing from the scope of the appended claims.In the claims,Any reference symbol between parentheses should not be configured to limitations on claims.Word "comprising" does not exclude the presence of notElement or step listed in the claims.Word "a" or "an" located in front of the element does not exclude the presence of multiple suchElement.The present invention can be by means of including the hardware of several different elements and being come by means of properly programmed computer realIt is existing.In the unit claims listing several devices, several in these devices can be through the same hardware branchTo embody.The use of word first, second, and third does not indicate any sequence.These words can be explained and be run after fameClaim.