-
Notifications
You must be signed in to change notification settings - Fork 78
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
tcp: listener: Add bind_device option #158
Conversation
You don't bother me at all! Thanks for making |
src/adapters/tcp.rs
Outdated
} | ||
|
||
socket.bind(&addr.into())?; | ||
socket.listen(1024)?; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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? 😇
eb857ac
to
da6586e
Compare
Add option to bind TCP listeners to a specific device, identified by its name. Signed-off-by: Konrad Gräfe <[email protected]>
da6586e
to
c7020c5
Compare
/// The maximum length of the pending (unaccepted) connection queue of a listener. | ||
pub const LISTENER_BACKLOG: c_int = 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks!!
May I ask you to make another release? |
Done! it's |
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 receivedTCP SYN
on the other interface. :-\ Therefore a TCP connection cannot be established.