Async I/O in Depth: Iterative TCP Echo Server



Async I/O in Depth: Iterative TCP Echo Server

Async I/O in Depth: Iterative TCP Echo Server

This series explores Asynchronous I/O in Rust. With this video we implement a simple TCP Echo Server and Client using the TcpListener and TcpStream structs. We start out by covering system architectures, working with the operating system, differences between blocking and non-blocking operations, system calls, computational vs I/O bound applications. We also take a look at libc crate to perform foreign function interface calls to the operating system with syscalls to get an idea of what all the libraries are doing underneath at the lowest level (aside from performing assembly instructions). We understand that all system calls that deal with I/O will typically deal with file descriptors (including stdin and stdout). Finally, after implementing the echo server with a TcpListener and TcpStream client, we take a look at an implementation with libc to create syscalls using the unsafe keyword in order to manage the file descriptor and system calls ourselves.

*NOTE*
This is the first video of a series covering async i/o in rust where we will eventually get to creating our own Async Runtime and working with Futures. Stay tuned!

↠ References:
std::net::TcpListener: https://doc.rust-lang.org/std/net/struct.TcpListener.html
std::net::SocketAddr: https://doc.rust-lang.org/std/net/enum.SocketAddr.html
std::net::TcpStream: https://doc.rust-lang.org/std/net/struct.TcpStream.html
std::io::Stdin: https://doc.rust-lang.org/std/io/struct.Stdin.html
std::io::Stdout: https://doc.rust-lang.org/stable/std/io/fn.stdout.html
socket: https://man7.org/linux/man-pages/man2/socket.2.html
setsocketopt: https://linux.die.net/man/2/setsockopt
bind: https://man7.org/linux/man-pages/man2/bind.2.html
listen: https://man7.org/linux/man-pages/man2/listen.2.html
connect: https://man7.org/linux/man-pages/man2/connect.2.html
write: https://man7.org/linux/man-pages/man2/write.2.html
read: https://man7.org/linux/man-pages/man2/read.2.html
close: https://man7.org/linux/man-pages/man2/close.2.html
libc crate: https://github.com/rust-lang/libc

↠ Patreon: https://www.patreon.com/nyxtom?fan_landing=true
↠ Dotfiles: https://github.com/nyxtom/dotfiles
↠ Twitter: @nyxtom https://twitter.com/nyxtom
↠ Channel: https://www.youtube.com/c/nyxtom

Cheers! 🍻

🦀 #rust #rustlang #rustprogramming #exercises #programming .

Comments are closed.