Question

I am looking for a reliable STUN solution for the TCP flow. I have tried STUNT (by cornell University in the US) and XSTUNT (by a University in Taiwan). But they both seem old and useless.

What I want to do is to transfer files between two clients in two different networks via C#. Please let me know if you have any solution for either of the following:

  1. And UDP-based Client/Server solutions for C#
  2. Any TCP-based STUN server
Était-ce utile?

La solution

Stuntman is a STUN server that supports TCP STUN.

www.stunprotocol.org

On that site, there's some links to some sample code, including C# implementations for client libraries. Most all are for UDP, but with a little work you can role your own C# code for TCP STUN by modifying one of the existing UDP code bases.

Afterwards, you will still need to implement a signaling service for exchanging address candidates (obtained directly or via STUN) and doing your own ICE-like connectivity checks.

For TCP, the easy solutions is to have both endpoints using two sockets. One socket or listening and another for connecting - but both share the same local port (ala SO_REUSEADDR socket option).

Another solution is to have each endpoint use just one socket. Both endpoints try repeatedly to do a TCP simultaneous connect. If the NAT's behave nicely, a connection can be made.

NAT traversal, especially TCP NAT Traversal, is not an exact science. There will always be cases where two endpoints can't get connected directly and will either have to fall back to UDP and/or go through a relay solution such as TURN.

Merge all the information above with the answer I wrote up last year on basic P2P/NAT traversal here.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top