Skip to content
/ beej-rs Public

"Beej's Guide to Network Programming" in Rust

License

Notifications You must be signed in to change notification settings

woile/beej-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beej-rs

An implementations in rust of the different code samples in Beej's Guide to Network Programming

Warning

The first few exercises were implemented using libc which has a lot of unsafe code. The latter exercises were impemented using nix which is a safer alternative.

Usage

> cargo run -- --help
Usage: beej-rs <COMMAND>

Commands:
  show-ip          Section 5.1 "getaddrinfo() -- Prepare to Launch": Show IP addresses
  stream-server    Section 6.1 "A Simple Stream Server": TCP server
  stream-client    Section 6.2 "A Simple Stream Client": TCP client
  socket-listener  Section 6.3 "Datagram Sockets": UDP server. From now on, we use `nix` for c bindings, which is a little bit safer than `libc`
  socket-talker    Section 6.3 "Datagram Sockets": UDP client
  poll-std-in      Section 7.2 "poll() - Synchonous I/O Multiplexing": Poll stdin for input
  poll-server      Section 7.2 "poll() - Synchonous I/O Multiplexing": Poll server for input
  select           Section 7.3 "select()—Synchronous I/O Multiplexing, Old School": Wait for something to appear on standard input
  select-server    Section 7.3 "select()—Synchronous I/O Multiplexing, Old School": Simple multi-user chat server
  broadcaster      Section 7.7 "Broadcast Packets—Hello, World!": A UDP Client that broadcasts
  help             Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Examples

  • Section 5.1 "getaddrinfo() -- Prepare to Launch"
  • Section 6.1 "A Simple Stream Server"
  • Section 6.2 "A Simple Stream Client"
  • Section 6.3 "Datagram Sockets" UDP Server
  • Section 6.3 "Datagram Sockets" UDP Client
  • Section 7.2 "poll() - Synchonous I/O Multiplexing"
  • Section 7.2 "poll() - Synchonous I/O Multiplexing"
  • Section 7.3 "select()—Synchronous I/O Multiplexing, Old School"
    • Bindings: nix
    • select from stdin
    • select.c -> select.rs
  • Section 7.3 "select()—Synchronous I/O Multiplexing, Old School"
  • Section 7.7 "Broadcast Packets—Hello, World!"

Note: the design of the cli grew organically as I was reading the book, so it's quite incoherent

About

"Beej's Guide to Network Programming" in Rust

Topics

Resources

License

Stars

Watchers

Forks

Languages