The content of the invention
In view of the above problems, it is proposed that the present invention, above mentioned problem or at least portion are overcome to provide one kind
The method and apparatus of a kind of access service solved the above problems with dividing, for solving to deposit in the prior art
Less efficient defect.
According to the first aspect of the present invention there is provided a kind of method for accessing service, including:
First terminal sets up the tunnel that can be communicated with second terminal;
The first terminal sends service access request by the tunnel to the second terminal, described
Service access request uses transmission control protocol TCP and/or user datagram udp protocol;
The first terminal receives the service access response that the second terminal is sent by the tunnel,
And associative operation is performed according to service access response, the service access response uses the TCP
And/or udp protocol.
In one embodiment, method described according to the abovementioned embodiments of the present invention, described first
Terminal sends service access request by the tunnel to the second terminal, including:
The application layer of the first terminal is set up TCP with the tunnel layer of the first terminal and is connected;
The tunnel layer of the first terminal determines TCP service requests port;
The service access request is passed through the TCP linkup transmits by the application layer of the first terminal
To the tunnel layer of the first terminal;
The tunnel layer of the first terminal is by the service access request from the TCP service request terminals
Mouth is sent to the tunnel layer of the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Service providing end mouthful in agreement and the second terminal that TCP service requests port is used is adopted
Agreement is identical.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The port of service providing end mouthful in the port numbering and the second terminal of TCP service requests port
Number identical or difference.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The application layer of first terminal and the tunnel layer of the first terminal are set up after TCP is connected, and described
Before the service access that the one terminal reception second terminal is sent by the tunnel is responded, the side
Method also includes:
The tunnel layer of the first terminal please by the TCP marks connected and/or TCP services
The port numbering of port is asked to send to the tunnel layer of the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
First terminal sends service access request by the tunnel to the second terminal, including:
The tunnel layer of the first terminal determines UDP service requests port;
The application layer of the first terminal sends the service access request to the first terminal
Tunnel layer;
The tunnel layer of the first terminal is by the service access request from the UDP service request terminals
Mouth is sent to the tunnel layer of the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Service providing end mouthful in agreement and the second terminal that UDP service requests port is used is adopted
Agreement is identical.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The port of service providing end mouthful in the port numbering and the second terminal of UDP service requests port
Number identical or difference.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The tunnel layer of first terminal determines after UDP service requests port that the first terminal receives described
Before the service access that second terminal is sent by the tunnel is responded, methods described also includes:
The tunnel layer of the first terminal by the port numbering of the UDP service requests port send to
The tunnel layer of the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, according to
The service access response performs associative operation, including:
The number for receiving the carrying connection identifier that the second terminal is sent is responded according to the service access
According to;
Fed back by being sent with the connection corresponding to the connection identifier to the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
First terminal sends service access request by the tunnel to the second terminal, including:
The first terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, by the tunnel to the second terminal send service access request;
The first terminal receives the service access response that the second terminal is sent by the tunnel,
Including:
The first terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, receive the service access that the second terminal sent by the tunnel and respond.
According to the second aspect of the present invention there is provided a kind of method for accessing service, including:
Second terminal sets up the tunnel that can be communicated with first terminal;
The second terminal receives the service access request that the first terminal is sent by the tunnel,
The service access request uses transmission control protocol TCP and/or user datagram udp protocol;
The second terminal is according to the service access request by the tunnel to the first terminal
Service access response is sent, the service access response uses the TCP and/or udp protocol.
In one embodiment, method described according to the abovementioned embodiments of the present invention, described second
Terminal is received by the tunnel after the service access request that the first terminal is sent, methods described
Also include:
The tunnel layer of the second terminal receives the service access request by the tunnel;
The tunnel layer of the second terminal is set up TCP with the service layer of the second terminal and is connected;
The tunnel layer of the second terminal is sent the service access request by the TCP connections
To the service providing end mouthful of the service layer of the second terminal.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Adopted TCP service requests port in agreement and the first terminal that service providing end mouth is used
Agreement is identical.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The port of TCP service requests port in the port numbering and the first terminal of service providing end mouthful
Number identical or difference.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Second terminal is sent to the first terminal by the tunnel according to the service access request and serviced
Before access response, methods described also includes:
The tunnel layer of the second terminal receives the mark for the TCP connections that the first terminal is sent
Knowledge and/or the port numbering of the TCP service requests port.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Second terminal receives the service access request that the first terminal is sent by the tunnel, including:
The tunnel layer of the second terminal receives the service access request by the tunnel;
The tunnel layer of the second terminal sends the service access request to the second terminal
Under the service providing end mouthful of service layer.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Adopted UDP service requests port in agreement and the first terminal that service providing end mouth is used
Agreement is identical.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
The port of UDP service requests port in the port numbering and the first terminal of service providing end mouthful
Number identical or difference.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Second terminal is sent to the first terminal by the tunnel according to the service access request and serviced
Before access response, methods described also includes:
The tunnel layer of the second terminal receives the UDP service requests that the first terminal is sent
The port numbering of port.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Second terminal is sent to the first terminal by the tunnel according to the service access request and serviced
After access response, methods described also includes:
The data for carrying connection identifier are sent to first terminal;
By receiving the feedback that the first terminal is sent with the connection corresponding to the connection identifier.
In certain embodiments, the method according to any of the above-described embodiment of the present invention, described
Second terminal receives the service access request that the first terminal is sent by the tunnel, including:
The second terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, pass through the tunnel and receive the service access request that the first terminal is sent;
The second terminal is according to the service access request by the tunnel to the first terminal
Service access response is sent, including:
The second terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, according to the service access request by the tunnel to the first terminal send take
Business access response.
According to the third aspect of the present invention there is provided a kind of first terminal, including:
Unit is set up, for setting up the tunnel that the first terminal can be communicated with second terminal;
Transmitting element, for sending service access request, institute to the second terminal by the tunnel
Service access request is stated using transmission control protocol TCP and/or user datagram udp protocol;
Receiving unit, rings for receiving the service access that the second terminal is sent by the tunnel
Should;
Processing unit, for performing associative operation, the service access according to service access response
Response uses the TCP and/or udp protocol.
In one embodiment, device described according to the abovementioned embodiments of the present invention, the foundation
Unit is additionally operable to, and controls the application layer of the first terminal to be set up with the tunnel layer of the first terminal
TCP connections;
The processing unit is additionally operable to, and controls the tunnel layer of the first terminal to determine that TCP services please
Ask port;
The transmitting element is additionally operable to, and controls the application layer of the first terminal please by the service access
Seek the tunnel layer by the TCP linkup transmits to the first terminal;
The transmitting element is additionally operable to, and controls the tunnel layer of the first terminal please by the service access
Ask and sent from the TCP service requests port to the tunnel layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Service providing end mouthful in agreement and the second terminal that TCP service requests port is used is adopted
Agreement is identical.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
The port of service providing end mouthful in the port numbering and the second terminal of TCP service requests port
Number identical or difference.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Transmitting element is additionally operable to, control mark that the tunnel layer of the first terminal connects the TCP and/
Or the port numbering of the TCP service requests port is sent to the tunnel layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Processing unit is additionally operable to, and controls the tunnel layer of the first terminal to determine UDP service requests port;
The transmitting element is additionally operable to, and controls the application layer of the first terminal please by the service access
Ask and send to the tunnel layer of the first terminal;
The transmitting element is additionally operable to, and controls the tunnel layer of the first terminal please by the service access
Ask and sent from the UDP service requests port to the tunnel layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Service providing end mouthful in agreement and the second terminal that UDP service requests port is used is adopted
Agreement is identical.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
The port of service providing end mouthful in the port numbering and the second terminal of UDP service requests port
Number identical or difference.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Transmitting element is additionally operable to, and controls the tunnel layer of the first terminal by the UDP service requests port
Port numbering send to the tunnel layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Receiving unit is additionally operable to, and is responded according to the service access and is received the carrying company that the second terminal is sent
Connect the data of mark;The transmitting element is additionally operable to, by with the connection corresponding to the connection identifier
Send and feed back to the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Transmitting element by the tunnel to the second terminal send service access request when, be specially:
Using the communication mode corresponding to the connected mode of the first terminal and the second terminal, lead to
Cross the tunnel and send service access request to the second terminal;
The receiving unit receives the service access response that the second terminal is sent by the tunnel
When, it is specially:
Using the communication mode corresponding to the connected mode of the first terminal and the second terminal, connect
Receive the service access response that the second terminal is sent by the tunnel.
According to the third aspect of the present invention there is provided a kind of second terminal, including:
Unit is set up, for setting up the tunnel that the second terminal can be communicated with first terminal;
Receiving unit, the service access for receiving the first terminal transmission by the tunnel please
Ask, the service access request is assisted using transmission control protocol TCP and/or user datagram UDP
View;
Transmitting element, for according to the service access request by the tunnel to the first terminal
Service access response is sent, the service access response uses the TCP and/or udp protocol.
In one embodiment, device described according to the abovementioned embodiments of the present invention, the reception
Unit is additionally operable to, and controls the tunnel layer of the second terminal to receive the service access by the tunnel
Request;
The unit of setting up is additionally operable to, and controls the tunnel layer and the second terminal of the second terminal
Service layer sets up TCP connections;
The transmitting element is additionally operable to, and controls the tunnel layer of the second terminal to connect by the TCP
Connect and send the service access request to the service providing end mouthful of the service layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Adopted TCP service requests port in agreement and the first terminal that service providing end mouth is used
Agreement is identical.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
The port of TCP service requests port in the port numbering and the first terminal of service providing end mouthful
Number identical or difference.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Receiving unit is additionally operable to, and controls the tunnel layer of the second terminal to receive the institute that the first terminal is sent
State the mark of TCP connections and/or the port numbering of the TCP service requests port.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Receiving unit is additionally operable to, and controls the tunnel layer of the second terminal to receive the service by the tunnel
Access request;
The transmitting element is additionally operable to, and controls the tunnel layer of the second terminal please by the service access
Ask and send to the service providing end mouthful of the service layer of the second terminal.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Adopted UDP service requests port in agreement and the first terminal that service providing end mouth is used
Agreement is identical.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
The port of UDP service requests port in the port numbering and the first terminal of service providing end mouthful
Number identical or difference.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Receiving unit is additionally operable to, and controls the tunnel layer of the second terminal to receive the institute that the first terminal is sent
State the port numbering of UDP service requests port.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
Transmitting element is additionally operable to, and the data for carrying connection identifier are sent to first terminal;
The receiving unit is additionally operable to, by receiving described the with the connection corresponding to the connection identifier
The feedback that one terminal is sent.
In certain embodiments, the device according to any of the above-described embodiment of the present invention, described
When receiving unit receives the service access request that the first terminal is sent by the tunnel, specifically
For:
The receiving unit is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, pass through the tunnel and receive the service access request that the first terminal is sent;
The transmitting element is according to the service access request by the tunnel to the first terminal
When sending service access response, it is specially:
The transmitting element is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, according to the service access request by the tunnel to the first terminal send take
Business access response.
In the embodiment of the present invention, a kind of method for accessing service is proposed:First terminal is set up can be with second
The tunnel that terminal is communicated;The first terminal is sent to the second terminal by the tunnel and serviced
Access request, using TCP, (Transmission Control Protocol are passed the service access request
Transport control protocol is discussed) and/or UDP (User Datagram Protocol, User Data Protocol) agreement;
The service access that the first terminal reception second terminal is sent by the tunnel is responded, and according to
Service access response performs associative operation, the service access response using the TCP and/or
Udp protocol;In this scenario, first terminal sets up the tunnel that can be communicated with second terminal;
Communicated by tunnel, and the service access request and the service access by tunnel transmission are rung
TCP and/or udp protocol should be used, and TCP and udp protocol are the more commonly used in the communications field,
And the storehouse of increasing income based on these agreements, framework, program are very common, it is not necessary to define new association
View, therefore, it can solve to access the relatively low defect of efficiency of service present in prior art.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the skill of the present invention
Art means, and can be practiced according to the content of specification, and in order to allow the present invention's above and other
Objects, features and advantages can become apparent, below especially exemplified by the embodiment of the present invention.
Embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although being shown in accompanying drawing
The exemplary embodiment of the disclosure, it being understood, however, that may be realized in various forms the disclosure without
It should be limited by embodiments set forth here.Conversely it is able to more thoroughly there is provided these embodiments
Understand the disclosure, and can by the scope of the present disclosure completely convey to those skilled in the art.
Fig. 1 schematically shows the stream of the method 10 of the access service according to embodiment of the present invention
Journey schematic diagram.As shown in figure 1, this method can include step 100,110 and 120.
Step 100:First terminal sets up the tunnel that can be communicated with second terminal;
Step 110:The first terminal sends service access by the tunnel to the second terminal
Request, the service access request uses TCP and/or udp protocol;
Step 120:The first terminal receives the service that the second terminal is sent by the tunnel
Access response, and associative operation is performed according to service access response, the service access response is adopted
With the TCP and/or udp protocol.
In the embodiment of the present invention, second terminal is interacted with supplementary mode with first terminal.Second eventually
End is interacted with supplementary mode with first terminal to be understood that:First terminal is an independence
Equipment, possesses one or more functions, and can be independently operated, second terminal has whole for first
End provides the effect of additional function or miscellaneous function, and function is more single, and generally requires connection
First terminal could be used, above-mentioned to only describe a kind of implementation, may be used also in actual applications
There can be a variety of situations, be not specifically limited herein.
In the embodiment of the present invention, first terminal and second terminal will be with a set patterns by the data of tunnel transmission
Model is encapsulated, such as defines packet specification in tunnel, the 0th~3 whole data packet length of byte representation,
For operation, (each agreement operates one corresponding with state to 4th~5 byte, such as with status identifier
0x01 represents that TCP connections are set up in request, and 0x02 represents to close TCP connections, 0x04 tables
Registration is according to transmission, and 0x08 represents connection error etc.), the 6th~9 byte representation TCP connections mark
Know, for being made a distinction with other TCP connection datas, the 10th~17 byte representation current tunnel
Layer can receive at present from receive first character joint number according to start counting up expiration data skew,
Receive sliding window, the data that the 18th byte representation sends for request application.
In the embodiment of the present invention, the first terminal is sent to the second terminal by the tunnel and taken
During access request of being engaged in, it is alternatively possible in the following way:
The application layer of the first terminal is set up TCP with the tunnel layer of the first terminal and is connected;
The tunnel layer of the first terminal determines TCP service requests port;
The service access request is passed through the TCP linkup transmits by the application layer of the first terminal
To the tunnel layer of the first terminal;
The tunnel layer of the first terminal is by the service access request from the TCP service request terminals
Mouth is sent to the tunnel layer of the second terminal.
In the embodiment of the present invention, alternatively, agreement that the TCP service requests port is used and
The agreement that service providing end mouth in the second terminal is used is identical.
For example, if service providing end mouthful uses Transmission Control Protocol, TCP service requests port is used
Agreement be Transmission Control Protocol.
In the embodiment of the present invention, alternatively, the port numbering of the TCP service requests port and institute
State service providing end in second terminal mouthful port numbering is identical or difference.
In the embodiment of the present invention, further, the application layer of the first terminal and the first terminal
Tunnel layer set up after TCP connections, the first terminal receive the second terminal pass through it is described
Before the service access response that tunnel is sent, methods described also includes following operation:
The tunnel layer of the first terminal please by the TCP marks connected and/or TCP services
The port numbering of port is asked to send to the tunnel layer of the second terminal.
In the embodiment of the present invention, the first terminal is sent to the second terminal by the tunnel and taken
During access request of being engaged in, it is alternatively possible in the following way:
The tunnel layer of the first terminal determines UDP service requests port;
The application layer of the first terminal sends the service access request to the first terminal
Tunnel layer;
The tunnel layer of the first terminal is by the service access request from the UDP service request terminals
Mouth is sent to the tunnel layer of the second terminal.
In the embodiment of the present invention, alternatively, agreement that the UDP service requests port is used and
The agreement that service providing end mouth in the second terminal is used is identical.
In the embodiment of the present invention, alternatively, the port numbering of the UDP service requests port and institute
State service providing end in second terminal mouthful port numbering is identical or difference.
In the embodiment of the present invention, further, the tunnel layer of the first terminal determines that UDP is serviced
Ask after port, the first terminal receives the service that the second terminal is sent by the tunnel
Before access response, methods described also includes following operation:
The tunnel layer of the first terminal by the port numbering of the UDP service requests port send to
The tunnel layer of the second terminal.
In the embodiment of the present invention, when performing associative operation according to service access response, alternatively,
Can be in the following way:
The number for receiving the carrying connection identifier that the second terminal is sent is responded according to the service access
According to;
Fed back by being sent with the connection corresponding to the connection identifier to the second terminal.
In the embodiment of the present invention, the first terminal is sent to the second terminal by the tunnel and taken
During access request of being engaged in, it is alternatively possible in the following way:
The first terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, by the tunnel to the second terminal send service access request;
The first terminal receives the service access response that the second terminal is sent by the tunnel,
Including:
The first terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, receive the service access that the second terminal sent by the tunnel and respond.
For example, being connected between first terminal and second terminal with USB, then first terminal is used
Usb communication mode, service access request is sent by tunnel to the second terminal, or, receive
The service access response that the second terminal is sent.
In the embodiment of the present invention, service access response can connect for return data, closing connection, refusal
The operation such as connect.
In this scenario, first terminal and second terminal are communicated by tunnel, and pass through tunnel transmission
Service access request and service access response use TCP and/or udp protocol, and TCP with
Udp protocol is the more commonly used in the communications field, and the storehouse of increasing income based on these agreements, framework, journey
Sequence is very common, it is not necessary to define new agreement, therefore, it can solve present in prior art
Access the relatively low defect of efficiency of service.
In the embodiment of the present invention, due to the physical communication layer between service layer and two terminals being carried out
Separation, so, when the communication mode between first terminal and second terminal changes not
Need to redefine new agreement, for example, the communication mode between first terminal and second terminal by
When USB modes are converted to bluetooth approach, it is not necessary to redefine new agreement.
Fig. 2 schematically shows the stream of the method 20 of the access service according to embodiment of the present invention
Journey schematic diagram.As shown in Fig. 2 this method can include step 200,210 and 220.
Step 200:Second terminal sets up the tunnel that can be communicated with first terminal;
Step 210:The second terminal receives the service that the first terminal is sent by the tunnel
Access request, the service access request uses transmission control protocol TCP and/or user datagram
Udp protocol;
Step 220:The second terminal is according to the service access request by the tunnel to described
First terminal sends service access response, and the service access response uses the TCP and/or UDP
Agreement.
In the embodiment of the present invention, second terminal is interacted with supplementary mode with first terminal.Second eventually
End is interacted with supplementary mode with first terminal to be understood that:First terminal is an independence
Equipment, possesses one or more functions, and can be independently operated, second terminal has whole for first
End provides the effect of additional function or miscellaneous function, and function is more single, and generally requires connection
First terminal could be used, above-mentioned to only describe a kind of implementation, may be used also in actual applications
There can be a variety of situations, be not specifically limited herein.
In the embodiment of the present invention, first terminal and second terminal will be with a set patterns by the data of tunnel transmission
Model is encapsulated, such as defines packet specification in tunnel, the 0th~3 whole data packet length of byte representation,
For operation, (each agreement operates one corresponding with state to 4th~5 byte, such as with status identifier
0x01 represents that TCP connections are set up in request, and 0x02 represents to close TCP connections, 0x04 tables
Registration is according to transmission, and 0x08 represents connection error etc.), the 6th~9 byte representation TCP connections mark
Show, for being made a distinction with other TCP connection datas, the 10th~17 byte representation current tunnel
Hold can receive at present from receive first character joint number according to start counting up expiration data skew,
Receive sliding window, the data that the 18th byte representation sends for request application.
In the embodiment of the present invention, the second terminal receives the first terminal by the tunnel and sent
Service access request after, further, methods described also includes following operation:
The tunnel layer of the second terminal receives the service access request by the tunnel;
The tunnel layer of the second terminal is set up TCP with the service layer of the second terminal and is connected;
The tunnel layer of the second terminal is sent the service access request by the TCP connections
To the service providing end mouthful of the service layer of the second terminal.
In the embodiment of the present invention, alternatively, agreement that service providing end mouth is used and described the
The agreement that TCP service requests port in one terminal is used is identical.
For example, if service providing end mouthful uses Transmission Control Protocol, TCP service requests port is used
Agreement be Transmission Control Protocol.
In the embodiment of the present invention, alternatively, the port numbering and described first of the service providing end mouthful
The port numbering of TCP service requests port in terminal is identical or difference.
In the embodiment of the present invention, further, the second terminal is logical according to the service access request
Cross the tunnel to the first terminal send service access response before, methods described also include it is as follows
Operation:
The tunnel layer of the second terminal receives the mark for the TCP connections that the first terminal is sent
Knowledge and/or the port numbering of the TCP service requests port.
In the embodiment of the present invention, the second terminal receives the first terminal by the tunnel and sent
Service access request when, it is alternatively possible in the following way:
The tunnel layer of the second terminal receives the service access request by the tunnel;
The tunnel layer of the second terminal sends the service access request to the second terminal
Under the service providing end mouthful of service layer.
In the embodiment of the present invention, alternatively, agreement that service providing end mouth is used and described the
The agreement that UDP service requests port in one terminal is used is identical.
In the embodiment of the present invention, alternatively, the port numbering and described first of the service providing end mouthful
The port numbering of UDP service requests port in terminal is identical or difference.
In the embodiment of the present invention, further, the second terminal is logical according to the service access request
Cross the tunnel to the first terminal send service access response before, methods described also include it is as follows
Operation:
The tunnel layer of the second terminal receives the UDP service requests that the first terminal is sent
The port numbering of port.
In the embodiment of the present invention, the second terminal passes through the tunnel according to the service access request
After sending service access response to the first terminal, methods described also includes following operation:
The data for carrying connection identifier are sent to first terminal;
By receiving the feedback that the first terminal is sent with the connection corresponding to the connection identifier.
In the embodiment of the present invention, the second terminal receives the first terminal by the tunnel and sent
Service access request when, it is alternatively possible in the following way:
The second terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, pass through the tunnel and receive the service access request that the first terminal is sent;
The second terminal is according to the service access request by the tunnel to the first terminal
Service access response is sent, including:
The second terminal is using corresponding to the connected mode of the first terminal and the second terminal
Communication mode, according to the service access request by the tunnel to the first terminal send take
Business access response.
For example, being connected between first terminal and second terminal with USB, then first terminal is used
Usb communication mode, service access request is sent by tunnel to the second terminal, or, receive
The service access response that the second terminal is sent.
In the embodiment of the present invention, service access response can connect for return data, closing connection, refusal
The operation such as connect.
In this scenario, first terminal and second terminal are communicated by tunnel, and pass through tunnel transmission
Service access request and service access response use TCP and/or udp protocol, and TCP/UDP
Agreement is the more commonly used in the communications field, and the storehouse of increasing income based on these agreements, framework, program are non-
Usually see, it is not necessary to define new agreement, therefore, it can solve to access present in prior art
The relatively low defect of efficiency of service.
In the embodiment of the present invention, due to the physical communication layer between service layer and two terminals being carried out
Separation, so, when the communication mode between first terminal and second terminal changes not
Need to redefine new agreement, for example, the communication mode between first terminal and second terminal by
When USB modes are converted to bluetooth approach, it is not necessary to redefine new agreement.
The embodiment of the present invention, it is also proposed that the embodiment of service is accessed, refering to shown in Fig. 3.
Step 300:First terminal sets up the tunnel that can be communicated with second terminal.
Wherein, second terminal in be connected or data such as service providing ends mouthful to provide service, first
Terminal selects idle, an agreement identical that the agreement of use is used with service providing end mouth
Intercept or wait pending data in TCP service requests port.
Step 310:The tunnel layer of the first terminal is sent to the second terminal by the tunnel and taken
Business access request, the service access request uses TCP and/or udp protocol.
In the step, first terminal and second terminal will be sealed by the data of tunnel transmission with certain specification
Dress, such as define packet specification in tunnel, the 0th~3 whole data packet length of byte representation, the
4~5 bytes are operation and status identifier (each one corresponding with state of agreement operation, such as 0x01
Represent that TCP connections are set up in request, 0x02 represents to close TCP connections, and 0x04 represents data
Transmission, 0x08 represents connection error etc.), the 6th~9 byte representation TCP connection identifier is used
Made a distinction in other TCP connection datas, the 10th~17 byte representation current tunnel layer is at present
Can receive from receive first character joint number according to start counting up expiration data skew, that is, receive
Sliding window, the data that the 18th byte representation sends for request application.
Step 320:The tunnel layer of second terminal is received after service access request, according to the envelope of agreement
Specification decapsulation is filled, initiates to operate to service layer port, such as sets up TCP connections, transmit TCP
Data etc..
Step 330:Second terminal sends service access to first terminal by tunnel and responded.
Wherein, service access response can be the packages such as return data, closing connection, refusal connection.
First terminal and second terminal are according to the continuous interactive communication of above-mentioned steps.
It should be noted that above-mentioned steps are a concrete case for accessing service, according to
It is actually needed, first terminal can provide multiple service providing ends mouthful, Huo Zhe in a service
Two terminals have multiple service providing ends mouthful to provide service, as long as pressing above-mentioned steps in first terminal
The mapping one by one of port and port is set up in the TCP service requests port opened as much.
As shown in fig.4, in the embodiment of the present invention, it is also proposed that a kind of first terminal 40, including:
Unit 400 is set up, for setting up the tunnel that the first terminal can be communicated with second terminal
Road;
Transmitting element 410, for sending service access request to the second terminal by the tunnel,
The service access request uses transmission control protocol TCP and/or user datagram udp protocol;
Receiving unit 420, for receiving the service access that the second terminal is sent by the tunnel
Response;
Processing unit 430, for performing associative operation, the service according to service access response
Access response uses the TCP and/or udp protocol.
In the embodiment of the present invention, second terminal is interacted with supplementary mode with first terminal.Second eventually
End is interacted with supplementary mode with first terminal to be understood that:First terminal is an independence
Equipment, possesses one or more functions, and can be independently operated, second terminal has whole for first
End provides the effect of additional function or miscellaneous function, and function is more single, and generally requires connection
First terminal could be used, above-mentioned to only describe a kind of implementation, may be used also in actual applications
There can be a variety of situations, be not specifically limited herein.
In the embodiment of the present invention, first terminal and second terminal will be with a set patterns by the data of tunnel transmission
Model is encapsulated, such as defines packet specification in tunnel, the 0th~3 whole data packet length of byte representation,
For operation, (each agreement operates one corresponding with state to 4th~5 byte, such as with status identifier
0x01 represents that TCP connections are set up in request, and 0x02 represents to close TCP connections, 0x04 tables
Registration is according to transmission, and 0x08 represents connection error etc.), the 6th~9 byte representation TCP connections mark
Show, for being made a distinction with other TCP connection datas, the 10th~17 byte representation current tunnel
Layer can receive at present from receive first character joint number according to start counting up expiration data skew,
Receive sliding window, the data that the 18th byte representation sends for request application.
In the embodiment of the present invention, further, the unit 400 of setting up is additionally operable to, and controls described the
The application layer of one terminal is set up TCP with the tunnel layer of the first terminal and is connected;
The processing unit 430 is additionally operable to, and controls the tunnel layer of the first terminal to determine that TCP takes
Business request port;
The transmitting element 410 is additionally operable to, and controls the application layer of the first terminal to visit the service
Ask tunnel layer of the request by the TCP linkup transmits to the first terminal;
The transmitting element 410 is additionally operable to, and controls the tunnel layer of the first terminal to visit the service
Ask that request is sent to the tunnel layer of the second terminal from the TCP service requests port.
In the embodiment of the present invention, alternatively, agreement that the TCP service requests port is used and
The agreement that service providing end mouth in the second terminal is used is identical.
For example, if service providing end mouthful uses Transmission Control Protocol, TCP service requests port is used
Agreement be Transmission Control Protocol.
In the embodiment of the present invention, alternatively, the port numbering of the TCP service requests port and institute
State service providing end in second terminal mouthful port numbering is identical or difference.
In the embodiment of the present invention, further, the transmitting element 410 is additionally operable to, and controls described the
The tunnel layer of one terminal is by the TCP marks connected and/or the end of the TCP service requests port
Mouth numbering is sent to the tunnel layer of the second terminal.
In the embodiment of the present invention, further, the processing unit 430 is additionally operable to, and controls described the
The tunnel layer of one terminal determines UDP service requests port;
The transmitting element 410 is additionally operable to, and controls the application layer of the first terminal to visit the service
Ask that request is sent to the tunnel layer of the first terminal;
The transmitting element 410 is additionally operable to, and controls the tunnel layer of the first terminal to visit the service
Ask that request is sent to the tunnel layer of the second terminal from the UDP service requests port.
In the embodiment of the present invention, alternatively, agreement that the UDP service requests port is used and
The agreement that service providing end mouth in the second terminal is used is identical.
In the embodiment of the present invention, alternatively, the port numbering of the UDP service requests port and institute
State service providing end in second terminal mouthful port numbering is identical or difference.
In the embodiment of the present invention, further, the transmitting element 410 is additionally operable to, and controls described the
The tunnel layer of one terminal sends the port numbering of the UDP service requests port to described second eventually
The tunnel layer at end.
In the embodiment of the present invention, further, the receiving unit 420 is additionally operable to, according to the clothes
Access response of being engaged in receives the data for the carrying connection identifier that the second terminal is sent;The transmitting element
410 are additionally operable to, and are fed back by being sent with the connection corresponding to the connection identifier to the second terminal.
In the embodiment of the present invention, alternatively, the transmitting element 410 is by the tunnel to described
When two terminals send service access request, it is specially:
Using the communication mode corresponding to the connected mode of the first terminal and the second terminal, lead to
Cross the tunnel and send service access request to the second terminal;
The receiving unit 420 receives the service access that the second terminal is sent by the tunnel
During response, it is specially:
Using the communication mode corresponding to the connected mode of the first terminal and the second terminal, connect
Receive the service access response that the second terminal is sent by the tunnel.
For example, being connected between first terminal and second terminal with USB, then first terminal is used
Usb communication mode, service access request is sent by tunnel to the second terminal, or, receive
The service access response that the second terminal is sent.
In the embodiment of the present invention, service access response can connect for return data, closing connection, refusal
The operation such as connect.
In this scenario, first terminal and second terminal are communicated by tunnel, and pass through tunnel transmission
Service access request and service access response use TCP and/or udp protocol, and TCP/UDP
Agreement is the more commonly used in the communications field, and the storehouse of increasing income based on these agreements, framework, program are non-
Usually see, it is not necessary to define new agreement, therefore, it can solve to access present in prior art
The relatively low defect of efficiency of service.
In the embodiment of the present invention, due to the physical communication layer between service layer and two terminals being carried out
Separation, so, when the communication mode between first terminal and second terminal changes not
Need to redefine new agreement, for example, the communication mode between first terminal and second terminal by
When USB modes are converted to bluetooth approach, it is not necessary to redefine new agreement.
As shown in fig.5, in the embodiment of the present invention, it is also proposed that a kind of second terminal 50, including:
Unit 500 is set up, for setting up the tunnel that the second terminal can be communicated with first terminal
Road;
Receiving unit 510, for receiving the service access that the first terminal is sent by the tunnel
Request, the service access request is assisted using transmission control protocol TCP and/or user datagram UDP
View;
Transmitting element 520, for according to the service access request by the tunnel to described first
Terminal sends service access response, and the service access response is assisted using the TCP and/or UDP
View.
In the embodiment of the present invention, second terminal is interacted with supplementary mode with first terminal.Second eventually
End is interacted with supplementary mode with first terminal to be understood that:First terminal is an independence
Equipment, possesses one or more functions, and can be independently operated, second terminal has whole for first
End provides the effect of additional function or miscellaneous function, and function is more single, and generally requires connection
First terminal could be used, above-mentioned to only describe a kind of implementation, may be used also in actual applications
There can be a variety of situations, be not specifically limited herein.
In the embodiment of the present invention, first terminal and second terminal will be with a set patterns by the data of tunnel transmission
Model is encapsulated, such as defines packet specification in tunnel, the 0th~3 whole data packet length of byte representation,
For operation, (each agreement operates one corresponding with state to 4th~5 byte, such as with status identifier
0x01 represents that TCP connections are set up in request, and 0x02 represents to close TCP connections, 0x04 tables
Registration is according to transmission, and 0x08 represents connection error etc.), the 6th~9 byte representation TCP connections mark
Show, for being made a distinction with other TCP connection datas, the 10th~17 byte representation current tunnel
Layer can receive at present from receive first character joint number according to start counting up expiration data skew,
Receive sliding window, the data that the 18th byte representation sends for request application.
In the embodiment of the present invention, further, the receiving unit 510 is additionally operable to, and controls described the
The tunnel layer of two terminals receives the service access request by the tunnel;
The unit 500 of setting up is additionally operable to, and controls the tunnel layer and described second of the second terminal eventually
The service layer at end sets up TCP connections;
The transmitting element 520 is additionally operable to, and controls the tunnel layer of the second terminal to pass through the TCP
Connect and send the service access request to the service providing end mouthful of the service layer of the second terminal.
In the embodiment of the present invention, alternatively, agreement that service providing end mouth is used and described the
The agreement that TCP service requests port in one terminal is used is identical.
For example, if service providing end mouthful uses Transmission Control Protocol, TCP service requests port is used
Agreement be Transmission Control Protocol.
In the embodiment of the present invention, alternatively, the port numbering and described first of the service providing end mouthful
The port numbering of TCP service requests port in terminal is identical or difference.
In the embodiment of the present invention, further, the receiving unit 510 is additionally operable to, and controls described the
The tunnel layers of two terminals receives the marks of the TCP connections that the first terminal is sent and/or described
The port numbering of TCP service requests port.
In the embodiment of the present invention, further, the receiving unit 510 is additionally operable to, and controls described the
The tunnel layer of two terminals receives the service access request by the tunnel;
The transmitting element 520 is additionally operable to, and controls the tunnel layer of the second terminal to visit the service
Ask that request is sent to the service providing end mouthful of the service layer of the second terminal.
In the embodiment of the present invention, alternatively, agreement that service providing end mouth is used and described the
The agreement that UDP service requests port in one terminal is used is identical.
In the embodiment of the present invention, alternatively, the port numbering and described first of the service providing end mouthful
The port numbering of UDP service requests port in terminal is identical or difference.
In the embodiment of the present invention, further, the receiving unit 510 is additionally operable to, and controls described the
The tunnel layer of two terminals receives the port for the UDP service requests port that the first terminal is sent
Numbering.
In the embodiment of the present invention, further, member 520 is additionally operable to, and the company of carrying is sent to first terminal
Connect the data of mark;
The receiving unit 510 is additionally operable to, by receiving institute with the connection corresponding to the connection identifier
State the feedback of first terminal transmission.
In the embodiment of the present invention, alternatively, the receiving unit 510 receives described by the tunnel
During the service access request that first terminal is sent, it is specially:
The receiving unit 510 is using the first terminal and the connected mode institute of the second terminal
Corresponding communication mode, the service access request that the first terminal is sent is received by the tunnel;
The transmitting element 520 is according to the service access request by the tunnel to described first
When terminal sends service access response, it is specially:
The transmitting element 520 is using the first terminal and the connected mode institute of the second terminal
Corresponding communication mode, is sent out according to the service access request by the tunnel to the first terminal
Take business access response.
For example, being connected between first terminal and second terminal with USB, then first terminal is used
Usb communication mode, service access request is sent by tunnel to the second terminal, or, receive
The service access response that the second terminal is sent.
In the embodiment of the present invention, service access response can connect for return data, closing connection, refusal
The operation such as connect.
In this scenario, first terminal and second terminal are communicated by tunnel, and pass through tunnel transmission
Service access request and service access response use TCP and/or udp protocol, and TCP/UDP
Agreement is the more commonly used in the communications field, and the storehouse of increasing income based on these agreements, framework, program are non-
Usually see, it is not necessary to define new agreement, therefore, it can solve to access present in prior art
The relatively low defect of efficiency of service.
In the embodiment of the present invention, due to the physical communication layer between service layer and two terminals being carried out
Separation, so, when the communication mode between first terminal and second terminal changes not
Need to redefine new agreement, for example, the communication mode between first terminal and second terminal by
When USB modes are converted to bluetooth approach, it is not necessary to redefine new agreement.
Method and apparatus are not solid with any certain computer, virtual system or miscellaneous equipment provided herein
There is correlation.Various general-purpose systems can also be used together with based on teaching in this.As described above,
It is obvious to construct the structure required by this kind of device.In addition, the present invention is not also for any specific
Programming language.It is understood that, it is possible to use various programming languages realize the content of invention described herein,
And the description done above to language-specific be in order to disclose the present invention preferred forms.
In the specification that this place is provided, numerous specific details are set forth.It is to be appreciated, however, that this
The embodiment of invention can be put into practice in the case of these no details.In some instances, not
Known method, structure and technology are shown specifically, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help to understand one in each inventive aspect
Or it is multiple, above in the description of the exemplary embodiment of the present invention, each feature of the invention is sometimes
It is grouped together into single embodiment, figure or descriptions thereof.However, should not be by the disclosure
Method be construed to reflect following intention:That is the present invention for required protection requirement is than in each claim
The middle more features of feature be expressly recited.More precisely, as the following claims reflect,
Inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows specific implementation
Thus claims of mode are expressly incorporated in the embodiment, wherein each claim is in itself
All as the separate embodiments of the present invention.
Those skilled in the art, which are appreciated that, to be carried out certainly to the module in the device in embodiment
Adaptively change and they are arranged in one or more devices different from the embodiment.Can be with
Some block combiners in embodiment into a module or unit or component, and in addition can be them
It is divided into multiple submodule or subelement or sub-component.Except in such feature and/or process or module
It is at least some exclude each other outside, can be using any combinations to this specification (including adjoint power
Profit is required, summary and accompanying drawing) disclosed in all features and so disclosed any method or equipment
All processes or unit be combined.Unless expressly stated otherwise, this specification (including adjoint power
Profit is required, summary and accompanying drawing) disclosed in each feature can or similar purpose identical, equivalent by offer
Alternative features are replaced.
Although in addition, it will be appreciated by those of skill in the art that some embodiments described herein include it
Included some features rather than further feature in its embodiment, but the not group of the feature of be the same as Example
Conjunction means to be within the scope of the present invention and forms different embodiments.For example, in claim
In book, the one of any of embodiment claimed mode can use in any combination.
The present invention each device embodiment can be realized with hardware, or with one or more processing
The software module run on device is realized, or is realized with combinations thereof.Those skilled in the art should
Understand, basis can be realized using microprocessor or digital signal processor (DSP) in practice
The some or all functions of some or all modules in the device of the embodiment of the present invention.The present invention is also
It can be implemented as some or all program of device (examples for performing method as described herein
Such as, computer program and computer program product).Such program for realizing the present invention can be stored in
On computer-readable medium, or there can be the form of one or more signal.Such signal can
Obtained, either provided or in any other form on carrier signal with being downloaded from internet website
There is provided.
It should be noted that the present invention will be described rather than limits the invention for above-described embodiment,
And those skilled in the art can design replacement without departing from the scope of the appended claims
Embodiment.In the claims, any reference symbol between bracket should not be configured to right
It is required that limitation.Word "comprising" does not exclude the presence of element or step not listed in the claims.It is located at
Word "a" or "an" before element does not exclude the presence of multiple such elements.The present invention can be by
Realized in the hardware for including some different elements and by means of properly programmed computer.Enumerating
If in the unit claim of equipment for drying, several in these devices can be by same hardware
Embody.The use of word first, second, and third does not indicate that any order.Can be by
These words are construed to title.