GithubHelp home page GithubHelp logo

Comments (7)

Frostie314159 avatar Frostie314159 commented on August 22, 2024 2

Sure, I'll get to this next week.

from socket2.

Frostie314159 avatar Frostie314159 commented on August 22, 2024 1

That setting is Apple specific, this is about the Linux socket option.

from socket2.

Thomasdezeeuw avatar Thomasdezeeuw commented on August 22, 2024

A pr to add this would be welcome.

from socket2.

carlocorradini avatar carlocorradini commented on August 22, 2024

Any update?
This is super useful ☺️🥳

from socket2.

Thomasdezeeuw avatar Thomasdezeeuw commented on August 22, 2024

Any update? This is super useful ☺️🥳

No pr was made, but they're still welcome.

from socket2.

Frostie314159 avatar Frostie314159 commented on August 22, 2024

I'm in the progress of writing one, however I'm not entirely sure how to go about it.

from socket2.

Thomasdezeeuw avatar Thomasdezeeuw commented on August 22, 2024

I just look at the code and we have Socket::bind_device_by_index_v4:

socket2/src/sys/unix.rs

Lines 2006 to 2045 in c93cdcc

pub fn bind_device_by_index_v4(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
let index = interface.map_or(0, NonZeroU32::get);
unsafe { setsockopt(self.as_raw(), IPPROTO_IP, libc::IP_BOUND_IF, index) }
}
/// Sets the value for `IPV6_BOUND_IF` option on this socket.
///
/// If a socket is bound to an interface, only packets received from that
/// particular interface are processed by the socket.
///
/// If `interface` is `None`, the binding is removed. If the `interface`
/// index is not valid, an error is returned.
///
/// One can use [`libc::if_nametoindex`] to convert an interface alias to an
/// index.
#[cfg(all(
feature = "all",
any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
)
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
feature = "all",
any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
)
)))
)]
pub fn bind_device_by_index_v6(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
let index = interface.map_or(0, NonZeroU32::get);
unsafe { setsockopt(self.as_raw(), IPPROTO_IPV6, libc::IPV6_BOUND_IF, index) }
}
. Or is this about another setting then IP_BOUND_IF?

from socket2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.