Jump to content
  • Advertisement
Sign in to follow this  
Akhilleus

UDP Sockets, C++, and Threading

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

Hi, I've got a basic system for sending/receiving UDP and I understand the concepts involved in making it reliable and ordering the packets, etc. However, I've never worked with UDP (or TCP/IP or anything internet-related!) and so while I understand how it works I'm not very familiar yet with everything about the system's implementation in code. As it seems to me it's necessary to do listening/sending in a dedicated thread, correct? I can't think of a better way to do it, unless the standard socket headers provide some sort of functionality of which I'm unaware. If this is the case (or even if it isn't), do you have any suggestions for a fast, platform-independent C++ threading library (of course one that I can legally use in a (potentially--who knows?) commercial product)? I've worked with wxWidgets and a few other APIs, but on this project speed (and memory) efficiency are obviously extremely important, so I'd really appreciate your suggestions. Thanks, -Akhilleus

Share this post


Link to post
Share on other sites
Advertisement
For any network coding in C++ I would recommend POCO libraries (http://pocoproject.org/). It has anything you need written in elegant C++ including customizable server application classes. It is not a gaming network library if that is what you are looking for though.

Share this post


Link to post
Share on other sites
No, you do not need a separate thread. For games, you can put the socket into non-blocking mode, where it won't wait for packets to arrive or sends to complete. You can then poll each frame.

enet is a simple robust cross-platform sockets wrapper with reliable UDP.

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!