socket2-ext

Crates.iosocket2-ext
lib.rssocket2-ext
version0.1.1
sourcesrc
created_at2024-04-14 06:56:00.41338
updated_at2024-04-15 11:54:24.53485
descriptionAn socket2 extension contains utilities for handling networking sockets with a maximal amount of configuration possible intended.
homepagehttps://github.com/cavivie/socket2-ext-rs
repositoryhttps://github.com/cavivie/socket2-ext-rs
max_upload_size
id1208068
size14,955
cavivie (cavivie)

documentation

README

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.

Commit count: 4

cargo fmt