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

SDLNet_CreateServer: set SO_REUSEADDR #88

Open
bog-dan-ro opened this issue Jan 29, 2024 · 0 comments
Open

SDLNet_CreateServer: set SO_REUSEADDR #88

bog-dan-ro opened this issue Jan 29, 2024 · 0 comments

Comments

@bog-dan-ro
Copy link

SO_REUSEADDR is needed to quickly reuse the same port after the application crash or forgets to close all connections properly.

int opt = 1;
setsockopt(server->handle, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));

just before int rc = bind(server->handle, addrwithport->ai_addr, addrwithport->ai_addrlen); will do the job.

Let me know if I shall create a PR for you.

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

1 participant