Files
tokio/src/net/mod.rs
T

47 lines
1.8 KiB
Rust
Raw Normal View History

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
//! [`connect`] method, which returns [`TcpStreamNew`]. `TcpStreamNew`
//! 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
//! [`TcpStreamNew`]: struct.TcpStreamNew.html
//! [`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.
//!
//! For convience it's also possible to convert raw datagrams into higher-level
//! frames. This done with [`UdpFramed`], created by calling [`framed`] on a
//! [`UdpSocket`], and using the [`UdpCodec`].
//!
//! [`UdpSocket`]: struct.UdpSocket.html
//! [`RecvDgram`]: struct.RecvDgram.html
//! [`SendDgram`]: struct.SendDgram.html
//! [`UdpFramed`]: struct.UdpFramed.html
//! [`framed`]: struct.UdpSocket.html#method.framed
//! [`UdpCodec`]: trait.UdpCodec.html
2016-09-02 11:07:52 -07:00
mod tcp;
mod udp;
pub use self::tcp::{TcpStream, TcpStreamNew};
2016-09-07 16:11:19 -07:00
pub use self::tcp::{TcpListener, Incoming};
2016-11-22 15:36:19 -08:00
pub use self::udp::{UdpSocket, UdpCodec, UdpFramed, SendDgram, RecvDgram};