socket2_ext/
lib.rs

1//! This crate provides some extensions and utils for socket2 operations.
2//!
3//! ## Example
4//!
5//! Cargo.toml:
6//!
7//! ```toml
8//! [dependencies]
9//! socket-ext = "0.1.0"
10//! socket2 = "0.5.6"
11//! ```
12//!
13//! main.rs:
14//! ```
15//! use socket2_ext::{AddressBinding, BindDeviceOption};
16//!
17//! let iface = "your/interface/name";
18//! match socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::DGRAM, None) {
19//!     Err(e) => println!("create socket error: {:?}", e),
20//!     Ok(socket) => {
21//!         if let Err(e) = socket.bind_to_device(BindDeviceOption::v4(iface)) {
22//!             println!("bind device error: {:?}", e);
23//!         }
24//!     }
25//! }
26//! ```
27pub mod binds;
28pub mod utils;
29
30pub use binds::{AddressBinding, BindDeviceOption};
31
32pub use socket2;