Jump to content
  • Advertisement

Archived

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

Robinhood

UDP help

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

1.Use just one port for 1000 clients. 2.Use several ports for 1000 clients. who can tell me which is feasible

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Magmai Kai Holmlor
Feasible? Both.

I really would like to know the limit!

Share this post


Link to post
Share on other sites
> Can you explain the detail?

Nothing magic here. Ports are OS abstractions and more of them opened won''t make your network card go any faster. Having one port per user allows you to have a separate buffer, but then having 000s of them eats up memory that needs to get pinned down in physical RAM. You''re better off with a single port and perform a client lookup based on the incoming IP & port.

If you plan on a Windows NT/2K/XP -only solution, then you should investigate IOCP. Here is some source code you can sink your teeth into: http://pages.infinit.net/cbenoi1/iocp_udp.zip

-cb

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Moderators: This thread should be moved to the "Multiplayer and Network Programming" forum for better feedback.

Share this post


Link to post
Share on other sites
Having one port should work - provided you can read the packets fast enough. If you can''t, then nothing would really work anyway.

On approach is to create a STL map which maps IP addresses (or for completeness, IP address, port number pairs) on to some kind of object which you store the connection info in.

The connection info would be dynamically stored in a struct or object, when each packet arrives you can do a key lookup on the map to find out which client it was from.

Because of course, packet spoofing could be used to DoS, you could create some kind of connection key which would be added to the packet somewhere, and check it matches.

Then the only tricky bit is, somewhere in your main loop you have to periodically check for clients which have gone dead, and disconnect them (thus freeing resources).

One approach I''ve used in a (non-game) project, is to keep a priority queue, and queue tasks on to it based on the time they next need attention (for example, some processing or a disconnect timeout). Then just look at the head of the priority queue, work out how long to sleep for and wait for that long.

Mark

Share this post


Link to post
Share on other sites
The IP I got from the SOCKADDR_IN is just a virual IP,but what I need is a real IP for someone to send messages in.So what I want is how to get real IP of server and clients.

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!