rusnet 0.1.0

An extremely basic network protocol.
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented1 out of 6 items with examples
  • Size
  • Source code size: 8.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.26 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tduck973564

Rusnet

docs dependency status build status

An extremely basic network protocol.

This network protocol was made by me after I forgot to put a network protocol in my application.

Examples

use rusnet::*;
use std::net::{ TcpListener, TcpStream };

fn main() {
    let listener = TcpListener::bind(("127.0.0.1", 0)).unwrap();
    /* Usually this would be the client,
    but it is mocked for the sake of the example */
    let mut output = Stream::new(
        TcpStream::connect(
            listener.local_addr().unwrap()
        ).unwrap()
    ).unwrap();
    for stream in listener.incoming() {
        let mut input = Stream::new(stream.unwrap()).unwrap();
        input.write("Hello, World!".to_string()).unwrap();
        println!("{}", output.read().unwrap()); // This will print "Hello, World!"
        break;
    }
}