So, I was in the middle of the NAT traversal process.
The following scenario: I have two Android phones, and I want to connect them (sockets) using an HTTP server (both devices are behind NAT).
So far so good, both clients connect to the HTTP server, the HTTP server records its IP address and PORTS,
however, there is a small problem, since I use Java HttpDefaultClient (), it will change the port every time I send a request from the client to the server. Well, that sounds like a simple problem: let's just use Socket () to actually maintain a valid TCP connection on the server.
public Socket (InetAddress address, int port, InetAddress localAddr, int localPort) throws an IOException
I just use this class and put localPort something random that I will remember. Now I'm doing everything again, this time it seems that the port will not change as I want.
Now, after I have the IP and port of the opponent (it is also behind NAT), theoretically I can refuse the SERVER connection and use the same localPort that I already used to actually host the client server?
if, and now this is the part in which I have a question: 1) If I drop the HTTP server socket, will NAT understand this and delete the port mapping? (Which is bad) 2) How does a symmetrical cone pass? 3) do the STUN libraries work differently?
source
share