> Could you please elaborate a bit on that? I don't mind doing something like 
> waitFor acceptRequest. Is there a ready-to-use proc for that, or do you mean 
> I should implement it by reading from socket?

My example relies on a future, and 
[waitFor](https://github.com/nim-lang/Nim/blob/master/lib/pure/asyncdispatch.nim#L1678),
 blocks until the future has finished. The same applies to the asynchttpserver 
interface, which can either be invoked in an asynchronous fashion with await 
(in an async proc), or in a blocking manner by passing 
[sendHeaders](http://forum.nim-lang.org///nim-lang.org/docs/asynchttpserver.html#sendHeaders,Request,HttpHeaders)
 for example to **waitFor**.

I would not block in the proc itself, because then you can't choose between the 
two methods, but this can be achieved by replacing **Future[T] {.async.}** with 
**T** and **await** with **waitFor**, at least in simple cases.

Reply via email to