-
Notifications
You must be signed in to change notification settings - Fork 4
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
Local interface/ip #15
Comments
Good idea. If a local address is passed in, that would preclude the need to connect the socket, since the binding already establishes which interface will be used. Do you see this as one call, where either local or remote can be unspecified? Or two calls? |
¯\_(ツ)_/¯ It's a hard one. You could make the interface take a new enum type something like this: enum SocketAddresses {
Local(SocketAddr),
Remote(SocketAddr),
Both((SocketAddr, SocketAddr)),
}
impl From<(SocketAddr, SocketAddr)> for SocketAddresses { ... }
impl From<(Option<SocketAddr>, SocketAddr)> for SocketAddresses { ... }
impl From<(SocketAddr, Option<SocketAddr>)> for SocketAddresses { ... }
// I don't know if UdpSocket::connect works with a remote port of 0, but you could try each of these...
impl From<(IpAddr, IpAddr)> for SocketAddresses { ... } // Uses port = 0
impl From<(IpAddr, Option<IpAddr>)> for SocketAddresses { ... }
impl From<(Option<IpAddr>, IpAddr)> for SocketAddresses { ... }
pub fn interface_mtu<A>(addrs: A)
where SocketAddresses: From<A> { ... } |
larseggert
added a commit
that referenced
this issue
Sep 3, 2024
@martinthomson, is this what you had in mind? Fixes #15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The interface uses a remote address only.
UdpSocket::bind
takes a local address, which is presently unspecified. A more general approach would be to specify the local address in addition to the remote address.The text was updated successfully, but these errors were encountered: