Expand description
Network related types.
The network module support two types of protocols:
- Transmission Control Protocol (TCP) module provides three main types:
- A TCP stream between a local and a remote socket.
- A TCP listening socket, a socket used to listen for connections.
- A TCP server, listens for connections and starts a new actor for each.
- User Datagram Protocol (UDP) only provides a single socket type:
I/O with Heph’s socket
The different socket types provide two or three variants of most I/O
functions. The try_* funtions, which makes the system calls once. For
example TcpStream::try_send calls send(2) once, not handling any
errors (including WouldBlock errors!).
In addition they provide a Future function which handles would block
errors. For TcpStream::try_send the future version is TcpStream::send,
i.e. without the try_ prefix.
Finally for a lot of function a convenience version is provided that handle
various cases. For example with sending you might want to ensure all bytes
are send, for this you can use TcpStream::send_all. But also see
functions such as TcpStream::recv_n; which receives at least n bytes,
or TcpStream::send_entire_file; which sends an entire file using the
sendfile(2) system call.
Notes
All types in the net module are bound to an actor. See the Bound
trait for more information.