import scalaz._, Scalaz._ import scala.util.control.Exception object Server extends App { def client[A](f: nio.Http => A) = { val client = new nio.Http (Exception ultimately client.shutdown())(f(client)) } def hello(client: nio.Http) = unfiltered.netty.async.Planify { case req => req.respond(ResponseString("hello world")) } def server(port: Int)(client: nio.Http) = unfiltered.netty.Http(port).plan(hello(client)) client(server(8080) _ >>> (_.run())) } object Client extends App { Server.client { c => val server = Server.server(8000)(c) server.start() Application launch classOf[Client] server.stop() server.destroy() } }