Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JeReK

UDP Network game problem ...

This topic is 5678 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

Hello, i need some help. I''m making an udp network engine, and I would like to receive only from IP that I specified in a SOCKADDR struct .. can you help me with some code??? Thanks.. Sorry for my english..

Share this post


Link to post
Share on other sites
Advertisement
You should look into connected UDP sockets if there is a compelling reason for you to use this method. Using connect() with UDP is somewhat misleading, so make sure you read up on it before you blindly trust what is going on... Stevens has a good treatment on connect() with UDP.

Share this post


Link to post
Share on other sites
Essentially you would have to track the connected clients within your server. One suggestion would be to store the IP addresses of the connected clients in a std::map. So, when a client connects to the server using the login protocol that you create (udp is connectionless) you would go through the usual validation of username and password then store the IP address in the std::map – then as further messages are received by the server you would have to verify that the IP address is in the connected list of clients.

Using a std::map allows you to quickly lookup the IP address over a std::list or std::vector. And I would be amiss to mention that there is more to this than that which I have alluded to but, this _is_ the general ideal.


Dave "Dak Lozar" Loeser

Share this post


Link to post
Share on other sites

  • 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!