Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Add support for SO_REUSEADDR socket address #5

Closed
cipriancraciun opened this issue May 26, 2020 · 3 comments
Closed

Add support for SO_REUSEADDR socket address #5

cipriancraciun opened this issue May 26, 2020 · 3 comments

Comments

@cipriancraciun
Copy link
Contributor

By default, at least on Linux, if I start catflap, then kill it and start it again (within a few seconds), it fails with Could not bind: EADDRINUSE: Address already in use, although there isn't any process actually listening on that endpoint (as confirmed by netstat); this is because the TCP/IP stack on Linux disallows the usage of the same endpoint for a time if any "delayed" packets might be received.

In order to allow the immediate restart of catflap, the SO_REUSEADDR socket address must be set when creating the socket. (This would be perhaps useful by default given that catflap is mainly meant for development purposes.)

(If accepted I'm willing to provide the patch.)

@passcod
Copy link
Owner

passcod commented May 27, 2020

Would merge a patch on this too! except may as well do it outright and don't even add an option to disable, unless there's a downside?

@cipriancraciun
Copy link
Contributor Author

[...] don't even add an option to disable, unless there's a downside?

To my knowledge there is no downside. (In all tools I've written, and in all production servers, I always configure the SO_REUSEADDR option.)


However I think this option is not accessible on all operating systems. How should I handle this? (I could add that option only on Linux.)

@passcod
Copy link
Owner

passcod commented May 27, 2020

Wherever it compiles, and if that's only linux then sure.

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

No branches or pull requests

2 participants