Module tokio::net [] [src]

TCP/UDP bindings for tokio.

This module contains the TCP/UDP networking types, similar to the standard library, which can be used to implement networking protocols.

TCP

Connecting to an address, via TCP, can be done using TcpStream's connect method, which returns ConnectFuture. ConnectFuture implements a future which returns a TcpStream.

To listen on an address TcpListener can be used. TcpListener's incoming method can be used to accept new connections. It return the Incoming struct, which implements a stream which returns TcpStreams.

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.

Structs

ConnectFuture

Future returned by TcpStream::connect which will resolve to a TcpStream when the stream is connected.

Incoming

Stream returned by the TcpListener::incoming function representing the stream of sockets received from a listener.

RecvDgram

A future used to receive a datagram from a UDP socket.

SendDgram

A future used to write the entire contents of some data to a UDP socket.

TcpListener

An I/O object representing a TCP socket listening for incoming connections.

TcpStream

An I/O object representing a TCP stream connected to a remote endpoint.

UdpFramed

A unified Stream and Sink interface to an underlying UdpSocket, using the Encoder and Decoder traits to encode and decode frames.

UdpSocket

An I/O object representing a UDP socket.