Poll for incoming events and drive futures on the same thread?

Oh, I see what you're asking now. Yes, you'll need to run the server future yourself. So it would be something like this:

let mut core = Core::new().unwrap();
let handle = core.handle();
let listener = TcpListener::bind(...).unwrap();
let server = listener.incoming().for_each(|sock, addr| {
      Http::new().bind_connection(&handle, sock, addr, <your_service>);
      Ok(())
});
core.run(server).unwrap();

So you bootstrap the inbound socket accept stream yourself, and then manually serve each accepted connection with the hyper service you wrote.

1 Like