would this work?

Started by
5 comments, last by JPulham 16 years, 1 month ago
I've been reading into NAT punch through for may game and think I finally have a good 'sequence of events'. My game is p2p with one peer being a 'host'/server. The only server we have is the web server (so no NAT introducer). I am using enet for communication. does this sound kinda right: * First I create a UDP socket to a STUN server; * I next perform STUN client stuff :P and find my extern. IP/port; * I post this to my lobby server (MySQL + PHP script) via HTTP; * While waiting for the first client send 'keepalive' through the socket (0xFF) & * once one client is connected I dont need 'keepalive' as the NAT table will be sustained by the keepalive sent by the game code. also - how often should I keep alive? 5sec, 10sec, 20sec... more? Less?
pushpork
Advertisement
That's not complete. You have to rendez-vous with the other client somehow. Thus, you'll have to check the web server for a matching client, that you can start sending packets to (and he can start sending packets to you).
enum Bool { True, False, FileNotFound };
sorry.. i didn't make myself clear...

the lobby server is a list of all 'hosts'. a client can then connect to one of the IP/Port combos from the web server.

but apart from that? thanks :D
pushpork
It's not good enough that a client connects to a server in that list.

The server needs to try to connect to the client at the same time as the client tries to connect to the server, or it won't work with restricted cone NAT (which is the most common kind AFAICT).

The question you need to answer is: "How does the server know that a client is trying to connect, so that the server can try to connect to the client?"
enum Bool { True, False, FileNotFound };
hmm... would it be possible to create a 'keep alive' connection in PHP?
Then the server would stay connected to the web server (in a minimal sense) during the lobby stage. When a client connects the SESSION (?) would be used to tell the server to start a connection job.

OR

maybe the server checks the lobby status every N seconds. once the lobby is full it sets the lobby ready flag and begins connecting to each client in the 'pre-game initialization'. Something like this might work (kinda :S)
pushpork
Yes, your second suggestion is in the right direction. Although trying to do this with a free web host is, to put it mildly, "not optimal."
enum Bool { True, False, FileNotFound };
Ok thanks... I'll go implement that.
Its not a free web host though, its paid. We recently updated our bandwidth etc due to number of visits... so it should be fine.
pushpork

This topic is closed to new replies.

Advertisement