Jump to content
  • Advertisement
Sign in to follow this  
JPulham

would this work?

This topic is 3873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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).

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
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."

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!