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

tcp: listener: Add bind_device option #158

Merged
merged 1 commit into from
May 12, 2023

Conversation

kgraefe
Copy link
Contributor

@kgraefe kgraefe commented May 11, 2023

Sorry to bother you again. It turns out my testing was not sufficient and I need an option to bind the listener to a specific interface as well, when I have multiple interfaces in the same (link-local) subnet. Otherwise the Linux kernel tries to send the TCP SYN/ACK on whichever interface was present first even when it received TCP SYN on the other interface. :-\ Therefore a TCP connection cannot be established.

@lemunozm
Copy link
Owner

You don't bother me at all! Thanks for making message-io better with your contributions 🤗

}

socket.bind(&addr.into())?;
socket.listen(1024)?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this magic number come from? Could it be addr.port instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the backlog value copied from https://docs.rs/mio/0.8.6/src/mio/net/tcp/listener.rs.html#77 (The maximum number of unaccepted TCP connections.)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment like this in the code for future readers? 😇

@kgraefe kgraefe force-pushed the tcp-listener-add-bind-device branch 3 times, most recently from eb857ac to da6586e Compare May 12, 2023 06:18
Add option to bind TCP listeners to a specific device, identified by its
name.

Signed-off-by: Konrad Gräfe <[email protected]>
@kgraefe kgraefe force-pushed the tcp-listener-add-bind-device branch from da6586e to c7020c5 Compare May 12, 2023 06:18
@kgraefe kgraefe requested a review from lemunozm May 12, 2023 06:29
Comment on lines +33 to +34
/// The maximum length of the pending (unaccepted) connection queue of a listener.
pub const LISTENER_BACKLOG: c_int = 1024;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks!!

@lemunozm lemunozm merged commit dfbe24c into lemunozm:master May 12, 2023
@kgraefe kgraefe deleted the tcp-listener-add-bind-device branch May 16, 2023 12:35
@kgraefe
Copy link
Contributor Author

kgraefe commented May 16, 2023

May I ask you to make another release?

@lemunozm
Copy link
Owner

Done! it's v0.17.0

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

Successfully merging this pull request may close these issues.

2 participants