mirror of
https://github.com/dadada/portfs.git
synced 2025-06-08 01:53:56 +02:00
Initial commit
This commit is contained in:
commit
97ee529bc7
4 changed files with 34 additions and 0 deletions
19
src/main.rs
Normal file
19
src/main.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use std::net::{TcpListener, TcpStream, SocketAddr};
|
||||
use std::io::Result;
|
||||
|
||||
fn handle_client(stream: TcpStream, addr: SocketAddr) {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let listener = TcpListener::bind("127.0.0.1:8080")?;
|
||||
|
||||
// accept connections and process them serially
|
||||
loop {
|
||||
match listener.accept() {
|
||||
Ok((socket, addr)) => handle_client(socket, addr),
|
||||
Err(e) => println!("could not accept client: {:?}", e),
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue