title: TCP connection between two android devices (even with NAT)
body: <p>I am doing an android app allowing users to play online.</p>
  
  <p>Currently, I use a TCP server: when two persons are connected, the server takes care of forwarding the packets between the two clients.</p>
  
  <p>I would like to replace my server by a java servlet with google app engine. This new server will just be used to connect the two players.</p>
  
  <p>It would work in that way:
  Player A opens a server socket and then post to the server the connection details.
  When a player B wants to play against A, he asks to the server the port number of A and he connects directly to A.</p>
  
  <p>The problem is that I am not sure that it will work if player A is behind a NAT. When player A opens a server socket, that opens one port of its 192.168.x.y address, but does it ask to the box a port forwarding? I assume it doesn't...</p>
  
  <p>So two questions:
  Is it possible to make a direct connection TCP between two devices even when there is a NAT or a firewall (I don't know how firewalls work on Android...)
  If it isn't possible, what is the best solution: Is it possible to make a TCP server to ensure the exchange of the messages with app engine?</p>
  
  <p>Thank you by advance.</p>
  
  <p><a href="https://play.google.com/store/apps/details?id=thibautperrin.tetrano" rel="nofollow">game</a></p>