#networking #configuration #utilities #sockets #handling

socket2

Utilities for handling networking sockets with a maximal amount of configuration possible intended

15 releases

0.3.8 Aug 30, 2018
0.3.7 Jun 27, 2018
0.3.5 Apr 17, 2018
0.3.4 Mar 13, 2018
0.2.1 Jun 13, 2017

#2 in Configuration

Download history 14885/week @ 2018-08-13 16512/week @ 2018-08-20 16631/week @ 2018-08-27 18242/week @ 2018-09-03 21714/week @ 2018-09-10 22681/week @ 2018-09-17 20815/week @ 2018-09-24 22003/week @ 2018-10-01 25380/week @ 2018-10-08 23334/week @ 2018-10-15 21549/week @ 2018-10-22 25231/week @ 2018-10-29 21864/week @ 2018-11-05

67,900 downloads per month
Used in 328 crates (14 directly)

MIT/Apache

140KB
3.5K SLoC

socket2-rs

Build Status Build status

Documentation

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Utilities for handling sockets

This crate is sort of an evolution of the net2 crate after seeing the issues on it over time. The intention of this crate is to provide as direct as possible access to the system's functionality for sockets as possible. No extra fluff (e.g. multiple syscalls or builders) provided in this crate. As a result using this crate can be a little wordy, but it should give you maximal flexibility over configuration of sockets.

Examples

use std::net::SocketAddr;
use socket2::{Socket, Domain, Type};

// create a TCP listener bound to two addresses
let socket = Socket::new(Domain::ipv6(), Type::stream(), None).unwrap();

socket.bind(&"[::1]:12345".parse::<SocketAddr>().unwrap().into()).unwrap();
socket.set_only_v6(false);
socket.listen(128).unwrap();

let listener = socket.into_tcp_listener();
// ...

Dependencies

~611KB