Sign in to follow this  

UDP Sockets, C++, and Threading

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

This topic is 3113 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.

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