Patent ID: 7797429

Claim:
A method for establishing Peer-to-Peer (P2P) connection, comprising the following computer-implemented steps: sending, by a first terminal, a connection request to a second terminal through a central server, and receiving from the second terminal a first response containing a port type of the second terminal; determining, by the first terminal, whether the port type of the second terminal is User Datagram Protocol (UDP) port or a Transmission Control Protocol (TCP) port; if determining that the port type of the second terminal is User Datagram Protocol (UDP) port, sending, by the first terminal, a message containing the local IP address/UDP port of the first terminal to the second terminal through the central server; returning, by the second terminal, a second response containing the local IP address/UDP port of the second terminal to the local IP address/UDP port of the first terminal upon receiving the message; and responding, by the first terminal, to the P2P connection upon receiving the second response, and establishing the P2P connection to the local IP address/UDP port of the second terminal in the second response; if determining that the port type of the second terminal is a Transmission Control Protocol (TCP) port, informing, by the first terminal, the second terminal of the IP address/TCP port of the first terminal, and sending, by the second terminal, a connection request to the IP address/TCP port of the first terminal to establish the P2P connection; wherein when the first terminal fails to receive the second response, the method further comprising the following computer-implemented steps: sending, by the first terminal, the message containing the public IP address/UDP port of the first terminal, to the second terminal; returning, by the second terminal, a third response containing the public IP address/UDP port of the second terminal to the public IP address/UDP port of the first terminal upon receiving the message; and responding, by the first terminal, to the P2P connection upon receiving the third response, and establishing the P2P connection to the public IP address/UDP port of the second terminal in the third response.