Server for Hole punching

Hi,
I have been interested in the Hole punching method for global communication directly without a server for a long time. In order for the communication to be established, however, I need a server for port forwarding and especially for sending the ip address of client A to client B and vice versa. I’m using Ngrok to run a web server, I made a simple script index.html, just to test some things and learn to work with it a bit. My idea is that the client would use Defold http request without connecting to the website. The http request should contain its own global ip address and, for example, a password for connecting specific clients. If the other client sent an http request with the same password, then it would receive the ip address of client A and client A would receive the ip address of client B. Then the hole punching itself could take place. But I still can’t figure out any method for a website to read an http request, save it, and then respond to it. I don’t get it very well, so I’d like someone who understands to help me.

A website can’t read http requests by itself. You need a server that can receive the request, parse it and optionally send back a response.

1 Like

Thank you very much. Is it possible to program something like this using Defold with the http extension or Lua socket?

Well, I mean, you will have no problems creating a Defold application that does http.requests() and socket/websocket requests. But the application needs to have a recipient, a server, or another client in the case of peer to peer socket connections. And for peer to peer connectivity you first need to discover the peer. This is usually done through a server and some matchmaking/discovery logic.

3 Likes