2017-12-05 16:55:25 +01:00
|
|
|
//! TCP/UDP bindings for `tokio`.
|
2016-09-02 11:07:52 -07:00
|
|
|
//!
|
|
|
|
|
//! This module contains the TCP/UDP networking types, similar to the standard
|
|
|
|
|
//! library, which can be used to implement networking protocols.
|
2017-12-05 16:55:25 +01:00
|
|
|
//!
|
|
|
|
|
//! # TCP
|
|
|
|
|
//!
|
|
|
|
|
//! Connecting to an address, via TCP, can be done using [`TcpStream`]'s
|
2018-02-06 08:09:00 +04:00
|
|
|
//! [`connect`] method, which returns [`ConnectFuture`]. `ConnectFuture`
|
2017-12-05 16:55:25 +01:00
|
|
|
//! implements a future which returns a `TcpStream`.
|
|
|
|
|
//!
|
|
|
|
|
//! To listen on an address [`TcpListener`] can be used. `TcpListener`'s
|
|
|
|
|
//! [`incoming`][incoming_method] method can be used to accept new connections.
|
|
|
|
|
//! It return the [`Incoming`] struct, which implements a stream which returns
|
|
|
|
|
//! `TcpStream`s.
|
|
|
|
|
//!
|
|
|
|
|
//! [`TcpStream`]: struct.TcpStream.html
|
|
|
|
|
//! [`connect`]: struct.TcpStream.html#method.connect
|
2018-02-06 08:09:00 +04:00
|
|
|
//! [`ConnectFuture`]: struct.ConnectFuture.html
|
2017-12-05 16:55:25 +01:00
|
|
|
//! [`TcpListener`]: struct.TcpListener.html
|
|
|
|
|
//! [incoming_method]: struct.TcpListener.html#method.incoming
|
|
|
|
|
//! [`Incoming`]: struct.Incoming.html
|
|
|
|
|
//!
|
|
|
|
|
//! # UDP
|
|
|
|
|
//!
|
|
|
|
|
//! The main struct for UDP is the [`UdpSocket`], which represents a UDP socket.
|
|
|
|
|
//! Reading and writing to it can be done using futures, which return the
|
|
|
|
|
//! [`RecvDgram`] and [`SendDgram`] structs respectively.
|
|
|
|
|
//!
|
2018-05-08 14:44:17 -04:00
|
|
|
//! For convenience it's also possible to convert raw datagrams into higher-level
|
2018-02-07 10:42:27 -08:00
|
|
|
//! frames.
|
2017-12-05 16:55:25 +01:00
|
|
|
//!
|
|
|
|
|
//! [`UdpSocket`]: struct.UdpSocket.html
|
|
|
|
|
//! [`RecvDgram`]: struct.RecvDgram.html
|
|
|
|
|
//! [`SendDgram`]: struct.SendDgram.html
|
|
|
|
|
//! [`UdpFramed`]: struct.UdpFramed.html
|
|
|
|
|
//! [`framed`]: struct.UdpSocket.html#method.framed
|
2016-09-02 11:07:52 -07:00
|
|
|
|
2018-03-15 03:38:59 +11:00
|
|
|
pub use tokio_tcp::{TcpStream, ConnectFuture};
|
|
|
|
|
pub use tokio_tcp::{TcpListener, Incoming};
|
|
|
|
|
pub use tokio_udp::{UdpSocket, UdpFramed, SendDgram, RecvDgram};
|
2018-08-16 06:26:10 +02:00
|
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
|
pub mod unix {
|
|
|
|
|
//! Unix domain socket bindings for `tokio`.
|
|
|
|
|
|
|
|
|
|
pub use tokio_uds::{
|
|
|
|
|
ConnectFuture, Incoming, RecvDgram, SendDgram, UCred, UnixDatagram, UnixListener,
|
|
|
|
|
UnixStream,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
|
pub use self::unix::{UnixListener, UnixStream};
|