Sign in to follow this  
JPulham

would this work?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?"

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this