Crates.io | socket2-ext |
lib.rs | socket2-ext |
version | 0.1.1 |
source | src |
created_at | 2024-04-14 06:56:00.41338 |
updated_at | 2024-04-15 11:54:24.53485 |
description | An socket2 extension contains utilities for handling networking sockets with a maximal amount of configuration possible intended. |
homepage | https://github.com/cavivie/socket2-ext-rs |
repository | https://github.com/cavivie/socket2-ext-rs |
max_upload_size | |
id | 1208068 |
size | 14,955 |
An socket2 extension contains utilities for handling networking sockets with a maximal amount of configuration possible intended.
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);
}
}
}
}
This project is licensed under the MIT license.
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.