However yeah - port-forwarding is literally impossible with code. Another benefit with hole-punching is that you can keep the logic in game-maker, which is pretty nice. It's not exactly trivial, but implementations exist and hole punching has been going on for years, so it's a totally valid technique. Then you'd see the port of the socket that made the broadcast and know your own port (although this may need online service to inform you of your own ip address first, as if you use localhost it may never even see the NAT.Ĭlick to expand.Depending on your hosting plan, where hosting an online multiplayer game isn't cheap - mind you - hole punching is a great technique for real time games that don't want to rely on a server or eat up the server's resources. On a further note, I am not sure if this would work but you could just open two UDP ports on your client, and send a broadcast to yourself. The first packet on each side will be blocked but the second one (and all the rest thereafter) will make it through. The two clients now have each other's details, so they send packets directly to each other. The server can see the ports that they used, and sends a packet back containing the port of the other user's port.Ĥ. Two users set up UDP sockets (with ports assigned by their NAT) and send any packet to that server, as they would normally to connect to any other UDP server.ģ. You, the developer sets up a port forwarded server for your users.Ģ. Click to expand.Even if the above method didn't work, holepunching still works with a NAT, you just need a port forwarded third party.ġ.