I am currently developing an android application which requires two devices to communicate over TCP (I can't silently loose packets so UDP is out). I need the communication to be as fast as possible (i.e. I have a low acceptable latency threshold) but the connections will be short lived (likely less than 2min). The phones will connect, do their thing, then close the connection.
I have done quite a bit of research regarding NAT hole punching, but there does not seem to be a reliable tcp hole punching method implemented for java and android. Thus, it seems my only option is to develop a server application which will "proxy" the tcp communications between the two devices.
I have two questions:
1) I don't want to re-invent the wheel: is there a simple tcp proxy already written I can use? (note: not an http proxy of any sort - because I need low latency I am simply looking to pass a very small payload between the two tcp socket connections on the devices). The sole purpose of the server is to avoid NAT issues.
2) If not, does anyone have experience with this sort of thing and what would they recommend? I have played around with the idea of Java NIO or perhaps a server that creates a new thread for each connection (the problem being how to link the appropriate "client" threads to pass the information back and forth). Or is Java even the best language to use for the server end?
I have read some recommendations of using XMPP via google's chat services (see here) but I don't want the overhead of XMPP.
Any direction or suggestions would be greatly appreciated.