Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are we sure we want to hardcode nonblocking mode for sockets? #113

Open
egnima opened this issue Jan 5, 2025 · 1 comment
Open

Are we sure we want to hardcode nonblocking mode for sockets? #113

egnima opened this issue Jan 5, 2025 · 1 comment

Comments

@egnima
Copy link

egnima commented Jan 5, 2025

Although non-blocking network operations are often preferred in gamedev, there are also plenty of times it's easier (and more CPU efficient) to use the operating systems designated blocking receive mode instead of while looping on a receive, especially if it's in a designated child thread.

I've started working on a PR that would add SetSocketBlockingMode and GetSocketBlockingMode (with nonblocking mode still the default), but I wasn't sure if that's the direction this library is going in. What do you experienced SDLers think?

@MrOnlineCoder
Copy link

I personally support this, it was surprising to me honestly that by default sockets are created in non blocking mode. More over, it's looks like it's not some built-in default behaviour, it is explicitly made non-blocking in places like this:

if (MakeSocketNonblocking(server->handle) < 0) {

So I would like to have the set/get functions for that at least, and to have sockets blocking by default at most.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants