aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: fcd9cfd4f2a3657463c3bca99219ad58b00e4750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::io::{self, Write};
use std::io::prelude::*;
use std::net::TcpListener;

fn open_stream() -> io::Result<()> {
    let listener = TcpListener::bind("127.0.0.1:34254")?;

    for stream in listener.incoming() {
        match stream {
            Ok(mut stream) => {
                let mut url = String::new();
                stream.read_to_string(&mut url)?;

                println!("{}", url);
            }
            Err(e) => {
                write!(io::stderr(), "{}", e)?;
            }
        }
    }

    Ok(())
}

fn main() {
    open_stream();
}