rusnet

Crates.iorusnet
lib.rsrusnet
version0.1.0
sourcesrc
created_at2021-09-01 08:37:19.154628
updated_at2021-09-01 08:37:19.154628
descriptionAn extremely basic network protocol.
homepage
repositoryhttps://github.com/tduck973564/rusnet
max_upload_size
id445503
size8,784
Thomas (tduck973564)

documentation

https://docs.rs/rusnet

README

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;
    }
}
Commit count: 0

cargo fmt