Specific embodiment
As shown in Figure 2, be embodiment of the invention communication system architecture schematic diagram, communication system comprises: terminal 21, gateway device 22 and server 23.
Terminal 21 comprises portable terminal, as mobile phone, personal digital assistant (PDA:Personal DigitalAssistant) etc. and fixed terminal, as landline telephone etc., be used for sending service request to gateway device 22, comprise the sign of the server 23 that request connects in the described service request; Gateway device 22 is used for the service request that receiving terminal 21 sends, and the sign of the server 23 that connects according to the request that comprises in the service request, judge whether and identify corresponding server 23 and set up and be connected (connecting) as TCP, if set up connection, judge whether to select described connection to transmit described service request to server 23, if select, then use described connection to transmit service request to server 23; Server 23 is used to receive the service request that gateway device 22 is transmitted.
Below on the basis of Fig. 2, in conjunction with Fig. 3 the embodiment of the invention is further described, as shown in Figure 3, a kind of concrete structure of gateway device 22 comprises: first receiving element 221, connection judgment unit 222, connection selected cell 223 and service request retransmission unit 224.
First receiving element 221 is used for the service request that receiving terminal 21 sends, and comprises the sign of server 23 of the connection of request in the described service request; Connection judgment unit 222 is used to judge whether set up with described sign corresponding server 23 and is connected; Can connection selected cell 223 be used for judgement and use described connection to transmit described service request to server 23; Service request retransmission unit 224 is used to use described connection to transmit described service request to server 23.
When the user stops using the value-added service that server 23 provides, use terminal 21 to send the professional request that disconnects to server 23, describedly professionally disconnect request and be submitted to gateway device 22; Gateway device 22 comprises that also second receiving element 225 is connected control unit 226 with first.Second receiving element 225 is used for the business disconnection of the transmission of receiving terminal 21 asks, the described professional sign that request comprises the server 23 of asking disconnection that disconnects; First connect control unit 226 be used for judging the described professional described sign corresponding server 23 that disconnects request connection whether idle, if idle, then disconnect described connection; The described connection free time is meant uses described connection after server 23 sends service request, and receives the service response at described service request that server 23 returns.
Whether connection free time of connect hours that gateway device 22 can also be by judging described connection or described connection overtime determines whether to disconnect described connection, as shown in Figure 4, gateway device 22 comprises: first receiving element 221, connection judgment unit 222, connection selected cell 223, service request retransmission unit 224 are connected control unit 227 with second.Second connects control unit 227 is used to judge whether connection free time of connect hours of described connection or described connection is overtime, if overtime, then disconnect and being connected with described sign; The described connection free time is meant uses described connection after server 23 sends service request, and receives the service response at described service request that server 223 returns.
In the above-mentioned communication system, receive the service request of terminal 21 transmissions when gateway device 22 after, judge to obtain having set up by connection judgment unit 222 and be connected with server 23, and connecting selected cell 223 judgements obtains selecting described connection when server 23 is transmitted described service request, service request retransmission unit 224 uses described connection to transmit described service request to server 23, can reduce gateway device 22 and server 23 number of times that connects and the linking number that is connected that reduces 23 maintenances of gateway device 22 and server, thereby can improve the burden that alleviates gateway device 22 and server 23, improve the handling property of gateway device 22, and the utilance that improves the network connection resource.Judge whether to select described connection to transmit described service request by connect connecting selected cell 223 to server 23, make gateway device 22 can support and stateless protocol server (as http server) between the mode of employing connection multiplexing communicate.Disconnect the sign of the server 23 that comprises in the request by first business that connects the transmission of the terminal 21 that control unit 226 receives according to second receiving element 225, judge obtain with server 23 set up described when being connected the free time, disconnect described connection, perhaps by second connect control unit 227 judge free time overtime or described connection connect hours of described connection overtime after, disconnect described connection, can reduce gateway device 22 and disconnect the number of times that is connected with server 23, improve the handling property and the burden that alleviates server 23 of gateway device 22, improve the utilance of network connection resource.
Fig. 5 is based on above-mentioned communication system, the communication means flow chart between gateway device and the server.In the present embodiment, the transport layer of setting up between gateway device 22 and the server 23 that is connected to is connected, for example TCP connection; Server 23 is stateless protocol server, for example http server.As shown in the figure, described communication means comprises the steps:
Step S502, the service request that receiving terminal 21 sends.When terminal 21 after server 23 sends service request, described service request is submitted to gateway device 22, the receiving element 221 in the gateway device 22 receives described service request.The sign that comprises server 23 in the described service request.
Step S504 judges whether to have set up with server 23 and is connected.After receiving element 221 received described service request, connection judgment unit 222 judged according to the sign of server 23 whether gateway device 22 has been set up with server 23 and is connected, if set up connection, and execution in step S506 then, if not, execution in step S510 then.
Step S506 judges whether to select described connection to transmit described service request to server 23.If connection judgment unit 222 judges that obtaining gateway device 22 has set up with server 23 and be connected, connect selected cell 223 and judge whether to select described connection to transmit described service request, if select execution in step S508 to server 23, if not, execution in step S510 then.
In the embodiment of the invention, can by but be not limited to following two kinds of methods and judge whether to select described connection to transmit described service request to server 23:
(1), judges whether described connection is idle.Judge that obtaining gateway device 22 uses described connection after server 23 sends service request if connect selected cell 223, and receive that server 23 returns at the service response of described service request the time, then described connection is idle, selects to use described connection to transmit described service request to server 23.
When being connected of gateway device 22 judgements and server 23 foundation is idle, use described connection to send service request to server 23, promptly after gateway device 22 receives the service response of a last service request, re-use described connection and send next service request to server 23.Under this method, connection selected cell 223 can be specially gateway device 22 and with 23 being connected of foundation of server status indicator is set, when gateway device 22 uses described connection after server 23 has sent service request, connect selected cell 223 described status indicators and be set to 1, represent that described connection is busy; When gateway device 22 receives the service response that server 23 returns by described connection after, connect selected cell 223 described status indicators and be set to 0, represent the described connection free time.Receive the service request of terminal 21 transmissions when gateway device 22 after, connect selected cell 223, judge whether described connection is idle specifically according to the described status indicator that is provided with.
(2), judge whether server 23 supports streamline (Pipeline) characteristic.Judge that when connecting selected cell 223 obtaining server 23 can receive a plurality of service request simultaneously, and when returning service response according to the sequencing that receives service request, then server 23 is supported pipeline characteristics, selects to use described connection to transmit described service request to server 23.
When gateway device 22 judges that obtaining server 23 supports the Pipeline characteristic, be that server 23 can receive a plurality of service request that gateway device 22 sends simultaneously, and according to the sequencing that the receives service request request of managing business and to gateway device 22 transmission business information responses (as the HTTP/1.1 server), gateway device 22 uses described connection to send service request to server 23.Under this method, connect selected cell 223 Pipeline server black and white lists can be set, the sign that is used to write down the sign of the server of supporting the Pipeline characteristic and does not support the server of Pipeline characteristic, connect selected cell 223 according to the sign of the server in the described service request 23 and the matching result of Pipeline server black and white lists, judge whether server 23 supports the Pipeline characteristic.Further, connect selected cell 223 the maximum traffic request number of while to the service request of server 23 transmissions can also be set, when the service request that sends to server 23 when 22 whiles of gateway device does not reach the largest request number of setting, then connect selected cell 223 judgements and obtain to use described connection to transmit described service request to server 23.
Certainly, also can adopt above-mentioned two kinds of methods to judge whether to use described connection to transmit described service request simultaneously,,, judge further then whether described connection is idle if do not support as judging whether server 23 supports the Pipeline characteristic earlier to server 23; Judge earlier that perhaps whether described connection is idle, if not idle, judges then whether server 23 supports the Pipeline characteristic again.
Obviously, above-mentioned steps S504 and step S506 can not have sequencing, can first execution in step S506, and back execution in step S504.
Step S508 uses described connection to transmit service request to server 23.According to the judged result among the step S506, gateway device 22 selects to use described connection to transmit service request to server 23.This method flow process finishes.
Step S510 connects with server 23, and uses described connection to transmit service request to server 23.This method flow process finishes.
In the foregoing description, if adopting, gateway device 22 judges to connect whether idle method judges whether to select described connection to transmit described service request to server 23, then gateway device 22 is a request one responses with the communication mode of server 23, be after gateway device 22 receives the service response at a last service request that server 23 returns, send next service request to server 23 again, so when gateway device 22 receive that server 23 returns service response after, described service response is transmitted to corresponding terminal.As shown in Figure 6, judge to connect whether idle method judges whether to select described connection when server 23 is transmitted described service request, the signaling process schematic diagram that terminal 21 is communicated by letter with server 23 for adopting when gateway device 22.In the embodiment of the invention, the transport layer of setting up between gateway device 22 and the server 23 that is connected to is connected, for example TCP connection; Server 23 is stateless protocol server, for example http server; Terminal A, terminal B and terminal C successively send to server 23 by gateway device 22 and use service request, and gateway device 22 does not connect with server 23 before receiving the service request that terminal A sends, and as shown in the figure, described signaling process comprises the steps:
Step S602, terminal A sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S604, gateway device 22 connects with server 23.After gateway device 22 receives described service request, sign judgement according to the server in the described service request 23 obtains not connecting with server 23, so gateway device 22 is set up new being connected with server 23 earlier before the service request of transmitting terminal A transmission.
Step S606, gateway device 22 use described connection to transmit the service request that terminal A sends to server 23.
Step S608, server 23 returns service response to gateway device 22.
Step S610, gateway device 22 is transmitted service response to terminal A.Because gateway device 22 is a request one responses with the communication mode of server 23, after gateway device 22 receives the service response that server 23 returns, just described service response is transmitted to terminal A.
Step S612, terminal B sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S614, gateway device 22 use described connection to transmit the service request that terminal B sends to server 23.After gateway device 22 receives described service request, judge according to the sign of the server in the described service request 23 and to obtain judging having set up and be connected with server 23, and described connection is idle, and gateway device 22 uses described connection to transmit the service request that terminal B sends to server 23.
Step S616, server 23 returns service response to gateway device 22.
Step S618, gateway device 22 is transmitted service response to terminal B.Because gateway device 22 is a request one responses with the communication mode of server 23, after gateway device 22 receives the service response that server 23 returns, just described service response is transmitted to terminal B.
Step S620, terminal C sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S622, gateway device 22 use described connection to transmit the service request of terminal C to server 23.After gateway device 22 receives described service request, judge to have set up with server 23 according to the sign of the server in the described service request 23 to be connected, and described connections is idle, gateway device 22 uses this connection to server 23 forwarding service request.
Step S624, server 23 sends service response to gateway device 22.
Step S626, gateway device 22 is transmitted service response to terminal C.Because gateway device 22 is a request one responses with the communication mode of server 23, after gateway device 22 receives the service response that server 23 returns, just described service response is transmitted to terminal C.
If adopting, gateway device 22 judges whether server 23 supports the method for Pipeline characteristic to judge whether to select described connection to transmit described service request to server 23, when then gateway device 22 judges that obtaining server 23 supports the Pipeline characteristic, gateway device 22 (is that server 23 can receive a plurality of service request that gateway device 22 sends with the communication mode of server 23 for many request multiple responses, and return service response) according to the sequencing that the receives service request request of managing business and to gateway device 22, after gateway device 22 receives the service response that server 23 returns, according to the corresponding relation of the sequencing of transmitting service request, the service response that receives is transmitted to the terminal 21 that sends service request with the sequencing that receives service response.As shown in Figure 7, judge whether server 23 supports the method for Pipeline characteristic to judge whether to select described connection when server 23 is transmitted described service request, the signaling process schematic diagram that terminal 21 is communicated by letter with server 23 for adopting when gateway device 22.In the embodiment of the invention, the transport layer of setting up between gateway device 22 and the server 23 that is connected to is connected, for example TCP connection; Server 23 is stateless protocol server, for example http server; Terminal A, terminal B and terminal C successively send to server 23 by gateway device 22 and use service request, gateway device 22 is before receiving the service request that terminal A sends, do not connect with server 23, and server 23 is supported the Pipeline characteristic, as shown in the figure, described signaling process comprises the steps:
Step S702, terminal A sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S704, gateway device 22 connects with server 23.After gateway device 22 receives described service request, sign judgement according to the server in the described service request 23 obtains not connecting with server 23, so gateway device 22 is set up new being connected with server 23 earlier before the service request of transmitting terminal A transmission.
Step S706, gateway device 22 use described connection to transmit the service request that terminal A sends to server 23.
Step S708, terminal B sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S710, terminal C sends service request to server 23, and service request is submitted to gateway device 22.The sign that comprises server 23 in the described service request.
Step S712, gateway device 22 use described connection to transmit the service request that terminal B sends to server 23.Gateway device 22 judges that according to the sign of the server in the described service request 23 obtaining server 23 supports the Pipeline characteristic, then uses described connection to transmit the service request of terminal B to server 23.
Step S714, gateway device 22 use described connection to transmit the service request that terminal C sends to server 23.Gateway device 22 judges that according to the sign of the server in the described service request 23 obtaining server 23 supports the Pipeline characteristic, then uses described connection to transmit the service request of terminal C to server 23.
Step S716, server 23 sends service response to gateway device 22.Because server 23 is supported the Pipeline characteristics, then server 23 is handled first service request that receives earlier according to the sequencing that receives service request, i.e. the service request that sends of terminal A, and return service response at terminal A to gateway device 22.
Step S718, gateway device 22 is transmitted service response to terminal A.Because server 23 is supported the Pipeline characteristic, server 23 sends service response according to the sequencing that receives service request to gateway device 22, so after the service response retransmission unit 227 in the gateway device 22 receives service response, also, first service response that receives is transmitted to terminal A according to the sequencing of transmitting service request.
Step S720, server 23 sends service response to gateway device 22.Because server 23 is supported the Pipeline characteristics, then server 23 is handled second service request that receives according to the sequencing that receives service request, i.e. the service request that sends of terminal B, and return service response at terminal B to gateway device 22.
Step S722, gateway device 22 is transmitted service response to terminal B.Because server 23 is supported the Pipeline characteristic, server 23 sends service response according to the sequencing that receives service request to gateway device 22, so after the service response retransmission unit 227 in the gateway device 22 receives service response, also, second service response that receives is transmitted to terminal B according to the sequencing of transmitting service request.
Step S724, server 23 sends service response to gateway device 22.Because server 23 is supported the Pipeline characteristics, then server 23 is handled the 3rd service request that receives according to the sequencing that receives service request, i.e. the service request that sends of terminal C, and return service response at terminal C to gateway device 22.
Step S726, gateway device 22 is transmitted service response to terminal C.Because server 23 is supported the Pipeline characteristic, server 23 sends service response according to the sequencing that receives service request to gateway device 22, so after the service response retransmission unit 227 in the gateway device 22 receives service response, also, the 3rd service response that receives is transmitted to terminal C according to the sequencing of transmitting service request.
In the embodiment of the invention, can disconnect and being connected of 23 of servers by following two kinds of methods:
(1), the business that sends of receiving terminal 21 disconnects request, and judge according to the described professional sign that disconnects the server 23 in the request and to obtain disconnecting described connection when idle with being connected of server 23.In the embodiment of the invention, after second receiving element 225 in the gateway device 22 receives the business disconnection request of terminal 21 transmissions, whether the sign judgement of the server 23 during the first connection control unit 226 is asked according to described professional disconnection is connected the free time with server 23 foundation, if the free time that is connected with described server, then disconnect described connection.The first connection control unit 226 can be specially gateway device 22 and with 23 being connected of foundation of server status indicator is set, when gateway device 22 uses described connection after server 23 has sent service request, first connects control unit 226 described status indicators is set to 1, represents that described connection is busy; When gateway device 22 received the service response that server 23 returns by described connection after, first connects control unit 226 described status indicators was set to 0, represent the described connection free time.When second receiving element 225 receives after business that terminal 21 sends disconnects request, first connects control unit 226 specifically according to the status indicator that is provided with, and determines whether described connection is idle.
(2), described connection is overtime or connection free time of described connection overtime after, disconnect described connection.In the embodiment of the invention, judge and obtain overtime or judge obtaining disconnecting described connection with after the free time that is connected of 23 foundation of server is overtime with the connect hours that is connected of 23 foundation of server when second in the gateway device 22 connects control unit 227.Concrete, when gateway device 22 connects with server 23 first, second connects the connect hours of the described connection of control unit 227 records, after second connect hours that connects control unit 227 definite described connections surpassed the predefined maximum connect hours, then disconnects described connection; Perhaps, when gateway device 22 and server 23 connect the free time, second connects the free time of the described connection of control unit 227 records, after second free time that connects the described connection of control unit 227 judgements surpassed predefined maximum idle time, then disconnects described connection.
Certainly, gateway device 22 can adopt above-mentioned two kinds of methods to disconnect and being connected of 23 of servers simultaneously.
In the above-mentioned communication means, after the service request that receives terminal 21 transmissions, be connected by judging to have set up with server 23, and judge and obtain to select described connection when server 23 is transmitted described service request, use described connection to transmit described service request to server 23, can reduce gateway device 22 and server 23 number of times that connects and the linking number that is connected that reduces 23 maintenances of gateway device 22 and server, thereby can alleviate the burden of gateway device 23 and server 23, improve the handling property of gateway device 22, and the utilance that improves connection resource.By judging whether to select described connection to transmit described service request to server 23, make gateway device 22 can support and stateless protocol server (as http server) between the mode of employing connection multiplexing communicate.Since can not identify in the service response returned of server 23 this service response at service request, the service response of returning by reception server 23, and according to the sequencing of service request retransmission unit 224 forwarding service request and the corresponding relation of the sequencing that receives service response, the service response that receives is transmitted to the terminal 21 that sends service request, can makes terminal 21 receive correct service response.The business of the transmission by receiving terminal 21 disconnects request, and according to the described professional sign that disconnects the server 23 in the request, judge with server 23 set up described when being connected the free time, disconnect described connection, when perhaps the free time of the overtime or described connection of connect hours by determining described connection is overtime, disconnect described connection, can reduce gateway device 22 and disconnect the number of times that is connected with server 23, improve the handling property and the burden that alleviates server 23 of gateway device 22, improve the utilance of network connection resource.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.