1//! Networking primitives.
2//!
3//! The types provided in this module are non-blocking by default and are
4//! designed to be portable across all supported Mio platforms. As long as the
5//! [portability guidelines] are followed, the behavior should be identical no
6//! matter the target platform.
7//!
8//! [portability guidelines]: ../struct.Poll.html#portability
9//!
10//! # Notes
11//!
12//! When using a datagram based socket, i.e. [`UdpSocket`] or [`UnixDatagram`],
13//! its only possible to receive a packet once. This means that if you provide a
14//! buffer that is too small you won't be able to receive the data anymore. How
15//! OSs deal with this situation is different for each OS:
16//! * Unixes, such as Linux, FreeBSD and macOS, will simply fill the buffer and
17//! return the amount of bytes written. This means that if the returned value
18//! is equal to the size of the buffer it may have only written a part of the
19//! packet (or the packet has the same size as the buffer).
20//! * Windows returns an `WSAEMSGSIZE` error.
21//!
22//! Mio does not change the value (either ok or error) returned by the OS, it's
23//! up to the user handle this. How to deal with these difference is still up
24//! for debate, specifically in
25//! <https://github.com/rust-lang/rust/issues/55794>. The best advice we can
26//! give is to always call receive with a large enough buffer.
27
28mod tcp;
29pub use self::tcp::{TcpListener, TcpStream};
30
31#[cfg(not(target_os = "wasi"))]
32mod udp;
33#[cfg(not(target_os = "wasi"))]
34pub use self::udp::UdpSocket;
35
36#[cfg(unix)]
37mod uds;
38#[cfg(unix)]
39pub use self::uds::{SocketAddr, UnixDatagram, UnixListener, UnixStream};
40