SHARE
TWEET

Untitled

a guest Jun 16th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let addr = "127.0.0.1:10228".parse().unwrap();
  3.     let listener = TcpListener::bind(&addr)
  4.         .expect("Unable to bind");
  5.    
  6.     let server = listener.incoming().for_each(move |mut sock| {
  7.         let (reader, writer) = sock.split();
  8.         let buffer = Vec::new();
  9.    
  10.         let handle_conn = tokio::io::read(reader, buffer)
  11.             .and_then(move |(r, b, len)| {
  12.                 info!("Got {:?}\namount of bytes: {}", b, len);
  13.                 Ok(())
  14.             }).map_err(|e| {error!("{}", e)});
  15.         tokio::spawn(handle_conn);
  16.         Ok(())
  17.     }).map_err(|e| {error!("{}", e)});
  18.    
  19.     tokio::run(server);
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top