2017-04-20 19:06:39 -05:00
|
|
|
use std::net::TcpListener;
|
|
|
|
use std::net::TcpStream;
|
|
|
|
use std::io::{self, Read, Write};
|
|
|
|
|
|
|
|
fn handle_client(stream: TcpStream) -> io::Result<()> {
|
|
|
|
stream.write_fmt(format!("message received"))
|
2018-07-19 07:15:43 -05:00
|
|
|
//~^ ERROR mismatched types
|
2017-04-20 19:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if let Ok(listener) = TcpListener::bind("127.0.0.1:8080") {
|
|
|
|
for incoming in listener.incoming() {
|
|
|
|
if let Ok(stream) = incoming {
|
|
|
|
handle_client(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|