So I was in a middle of making NAT traversal.
The scenario is next: I got two Android phones and I want to connect them(sockets) using HTTP server(both devices are behind NAT).
So far so good, both clients connect to HTTP server, HTTP server records their IP address&PORTS,
however there is a little problem, since I use Java HttpDefaultClient(), it will change the port each time I send request from client to the server. Okay that sounds like simple problem: let's just use Socket() to actually maintain a valid TCP connection into server.
public Socket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException
I will just use this class and put the localPort something random which I will remember. Now I do everything again, this time it seems that port wont change, like I want.
Now after I have opponent's IP&port(he's also behind NAT), theoretically I could drop the SERVER connection and use the same localPort I already used to actually host a clientServer?
unless, and now comes the part where I have question: 1)If I drop the HTTP server socket, will NAT understand that and remove the port mapping?(that's bad) 2) How does actually passing symmetric-cone nat work? 3) does the STUN libraries work somehow differently?