I have a question, I am creating a remote desktop control service, I have investigated and it turns out that I need an accessible public IP, so I saw that there are Stun servers that provide you with a public IP so that they can connect to your computer, my question is , when sending a UDP packet to the Stun server and it returned my public IP along with the port, do I need to keep the connection alive with the server? And how can the destination computer connect to the source computer? Do you need to connect to the Stun server and find the source computer there?
1 Answers
If your implementation is to keep pinging the STUN server until it becomes time to bridge a connection, that's not the best way. And I'll spare the details - but this technique will not work reliably for all networks.
A better approach:
Have your endpoint connect to a signaling service. This can be a persistent TCP connection to a server that forwards messages, a push notification, server, or some hybrid approach. SIP, XMPP, node-js server, cups-with-strings, will all work fine. The hosts connect to the signaling service and awaits a message telling that there's someone waiting to connect.
Then upon exchanging addresses over the signaling service, you can reliably establish a direct connection between both endpoints.
More details here: https://stackoverflow.com/a/8524609/104458

- 100,020
- 15
- 103
- 173