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

SO_REUSEADDR #97

Open
sheinb opened this issue Feb 25, 2024 · 3 comments
Open

SO_REUSEADDR #97

sheinb opened this issue Feb 25, 2024 · 3 comments
Assignees
Labels
fix added A fix was added but has yet to be fully tested/verified missing feature A feature that needs to be added
Milestone

Comments

@sheinb
Copy link
Contributor

sheinb commented Feb 25, 2024

From what I can tell, the default for tcp acceptors is now to not reuse addresses but there is a possibility of passing this as a parameter. I can't quite get this to work, though. The examples, using the constructor with "ec" passed, work fine, but if I try the alternate, with the last argument specified as the reuse argument (1?) I get compiler errors. Is there a working example using this option (or can I set REUSEADDR another way)?

@fpagliughi
Copy link
Owner

The code that's in master/develop is exceptionally unstable at the moment as I move toward the v2.0 API. So be warned it's not meant for production applications yet, will likely change, and may have some bugs... and missing features!

That said, I appreciate any comments, suggestions, and bug reports as this comes together.

I had received complaints that the acceptor in v1 was opinionated in regard to its choices of reuse, and I always felt a little weird that I kept it in when I released the library publicly, since the original design choice was for a specific machine I was working on long ago.

The idea now, as you probably guessed. is that it doesn't chose a specific reuse strategy, but defaults to the same as the underlying library - which is none. The acceptor's open() and bind() calls now take a reuse parameter which you can use to select SO_REUSEADDR or SO_REUSEPORT, or keep the default as zero/none.

As you discovered, I forgot to add a noexcept version of the constructor which includes this parameter. Sounds like I need to add this:

acceptor(const sock_address& addr, int queSize, int reuse, error_code& ec) noexcept;

I will get that added right away, and look at updating an example or two to show how to use it.

@fpagliughi fpagliughi self-assigned this Feb 26, 2024
@fpagliughi fpagliughi modified the milestones: v1.1, v2.0 Feb 26, 2024
@fpagliughi fpagliughi added the missing feature A feature that needs to be added label Feb 26, 2024
@sheinb
Copy link
Contributor Author

sheinb commented Feb 26, 2024 via email

@fpagliughi fpagliughi added the fix added A fix was added but has yet to be fully tested/verified label Feb 26, 2024
@fpagliughi
Copy link
Owner

Fix is up in the develop branch. I'll get it into master after some additional testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix added A fix was added but has yet to be fully tested/verified missing feature A feature that needs to be added
Projects
None yet
Development

No branches or pull requests

2 participants