简体   繁体   中英

Direct TCP/IP networking between two android devices over internet

Hey I am just a beginner at networking.

Is it possible to connect two android devices to each other using sockets over the Internet without using any intermediate dedicated server, Given that there are Nat routers in the wifi and GPRS/3G connections.

I heard that you need to send a outgoing message to other device first , then only NAT would allow that device to reply back to you. But when both device behind NAT how would the first message or packet reach to anyone of them?

EDIT : Observation-> When i query for location of my public IP address I get random places like other cities and sometimes other states!!! What's the matter? can anyone explain?

The overall design of such a solution involves the use of a third party server. In order for the clients to connect to each other, their public IP (ie, the NATs IP) has to be known to the other party. When I had to something similar, I implemented STUN , which is part of the ICE technique for establishing peer-to-peer connections. STUN supports both TCP and UDP-traffic. If you want to understand STUN, you should also read about TURN .

Even though STUN requires the user of a third-party for clients to be able to connect directly, there are many public STUN servers available. Here is one of the lists a quick-google search turned up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM