Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] UDP and firewall?

Author
Message
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Searching for The Dark Tower, I hope it is in Denmark, near
Posted: 10th Jan 2019 15:05
Hey How will UDP work with a firewall? I've been using sockets and regular networks messages, these can connect to host through a firewall because they connect to an IP address and a specified port which makes the firewall allow communication back to the client by routing the used port in the firewall. But with UDP, an UDP listener is created on both ends, how will I know which port the firewall routed to the port on the client?
13/0

The author of this post has marked a post as an answer.

Go to answer

Paul Johnston
TGC Developer
16
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Jan 2019 15:18
This post has been marked by the post author as the answer.
If you can get a packet from one client to the other then you can take the source port of the packet and use that as the destination port in the reply and the firewall will remember the source port it used and forward it back to the sender. However it does require that you can send packets one way to begin with, such as with port forwarding. If both clients have firewalls without port forwarding then a third party server is needed to negotiate the connection.
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Searching for The Dark Tower, I hope it is in Denmark, near
Posted: 10th Jan 2019 15:48
I already have a lobby server running 24/7 which also detects the IP of all connecting to it How do I get the source port from a packet? (Ah, I had not seen this command: GetNetworkMessageFromPort) Let me extend a thank you for all you and your coworkers' hard work, your products make it very easy to develop games from scratch. I have even sat down one evening to make some mockup graphics of how an app I would like to make could look like, one thing led to another and 3 AM in the morning I had a fully working app.
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Searching for The Dark Tower, I hope it is in Denmark, near
Posted: 11th Jan 2019 09:13
How do I negotiate the connection between two clients if they are both behind a firewall/NAT? Doesn't the firewall route the IP that the client sends to, and assigns a port that will route to the client? Or can I just send to the lobby server IP, read the port on the packet arrived at the lobby server, then tell the other client to use that port even though the client will send from an other IP address?
13/0
Paul Johnston
TGC Developer
16
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 11th Jan 2019 14:47
It depends on the firewall, there are versions that will only allow the specific IP and port combo to forward packets back to the sender behind the firewall, called symmetric NAT, however I think these are rare. The method you describe should work in other cases.

Login to post a reply

Server time is: 2019-03-20 20:51:32
Your offset time is: 2019-03-20 20:51:32