|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -//! Utilities for handling sockets |
| 11 | +// # Source code structure. |
| 12 | +// |
| 13 | +// All types and methods that are available on tier 1 all platforms are defined |
| 14 | +// in the first level of the source, i.e. `src/*.rs` files. Additional API that |
| 15 | +// is platform specific, e.g. `Domain::UNIX`, is defined in `src/sys/*.rs` and |
| 16 | +// only for the platforms that support it. |
| 17 | + |
| 18 | +//! Utilities for creating and using sockets. |
| 19 | +//! |
| 20 | +//! The goal of this crate is to create and use a socket using advanced |
| 21 | +//! configuration options (those that are not available in the types in the |
| 22 | +//! standard library) without using any unsafe code. |
| 23 | +//! |
| 24 | +//! This crate provides as direct as possible access to the system's |
| 25 | +//! functionality for sockets, this means **no** effort to provide |
| 26 | +//! cross-platform utilities, no extra goodies, no creature comforts. It is up |
| 27 | +//! to the user to know how to use sockets when using this crate. *If you don't |
| 28 | +//! know how to create a socket using libc/system calls then this crate is not |
| 29 | +//! for you*. Most, if not all, functions directly relate to the equivalent |
| 30 | +//! system call with no error handling applied, so no handling errors such as |
| 31 | +//! [`EINTR`]. As a result using this crate can be a little wordy, but it should |
| 32 | +//! give you maximal flexibility over configuration of sockets. |
12 | 33 | //!
|
13 |
| -//! This crate is sort of an evolution of the `net2` crate after seeing the |
14 |
| -//! issues on it over time. The intention of this crate is to provide as direct |
15 |
| -//! as possible access to the system's functionality for sockets as possible. No |
16 |
| -//! extra fluff (e.g. multiple syscalls or builders) provided in this crate. |
17 |
| -//! This also means it doesn't handle errors such as `EINTR`. As a result using |
18 |
| -//! this crate can be a little wordy, but it should give you maximal flexibility |
19 |
| -//! over configuration of sockets. |
| 34 | +//! [`EINTR`]: std::io::ErrorKind::Interrupted |
20 | 35 | //!
|
21 | 36 | //! # Examples
|
22 | 37 | //!
|
|
25 | 40 | //! use std::net::SocketAddr;
|
26 | 41 | //! use socket2::{Socket, Domain, Type};
|
27 | 42 | //!
|
28 |
| -//! // create a TCP listener bound to two addresses |
| 43 | +//! // Create a TCP listener bound to two addresses. |
29 | 44 | //! let socket = Socket::new(Domain::IPV6, Type::STREAM, None)?;
|
30 | 45 | //!
|
31 | 46 | //! let address: SocketAddr = "[::1]:12345".parse().unwrap();
|
|
0 commit comments