socket2-ext 0.1.1

An socket2 extension contains utilities for handling networking sockets with a maximal amount of configuration possible intended.
Documentation

socket2-ext-rs

An socket2 extension contains utilities for handling networking sockets with a maximal amount of configuration possible intended.

Crates.io MIT licensed Build Status

Example

Bind a socket to a specific device on Unix/Windows host platform.

use socket2_ext::binds::{AddressBinding, BindDeviceOption};

fn main() {
    let iface = "your/interface/name";
    match socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::DGRAM, None) {
        Err(e) => println!("create socket error: {:?}", e),
        Ok(socket) => {
            if let Err(e) = socket.bind_to_device(BindDeviceOption::v4(iface)) {
                println!("bind device error: {:?}", e);
            }
        }
    }
}

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.