0
votes

I have a situation where I used STUN to establish a UDP [RTP] connection between two clients so that they can stream media with one another with some packet loss. Now, they are done streaming media and one client would like to send the other client a large file. Rather than using UDP [RTP] to send the large file, I would find it more convenient, as a programmer, to send the file with TCP because TCP takes care of re-sending lost packets on my behalf. Can I just tell the client applications to stop using their UDP connections (say with "socket.close(); socket = null;") and immediately open up new TCP connections at the same port/address as the UDP connections? Will that work or will the three-way handshake get blocked? Is there a timing or security issue involved? In which cases will replacing hole punched UDP with TCP work and in which cases will it not work?

1
You can use STUN to help establish TCP connections between devices that are behind NATs. Although it is slightly more tricky and not as reliable as UDP. (Hint, both sides have to connect to each other simultaneously). Shameless plug: Stuntman supports TCP STUN.selbie

1 Answers

1
votes

TCP and UDP ports are different. A TCP socket at port 1000, is a completely different communication endpoint from a UDP socket at port 1000. So your application could just span a new thread, establish a new TCP connection and transfer the desired file. The UDP connection can continue the exchange of RTP packets.