Crate socket2[−][src]
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(); // ...
Structs
Domain | Specification of the communication domain for a socket. |
Protocol | Protocol specification used for creating sockets via |
SockAddr | The address of a socket. |
Socket | Newtype, owned, wrapper around a system socket. |
Type | Specification of communication semantics on a socket. |