Skip to content
Dominik Picheta edited this page Aug 28, 2017 · 4 revisions

This lists some commonly asked questions regarding the content of the book.

Confusing use of asyncCheck in Listing 3.26

A user named nsfw_ asked this on IRC: https://irclogs.nim-lang.org/28-08-2017.html#21:40:49.

This refers to the asyncCheck used for the connect call, on line 54:

...
var socket = newAsyncSocket()

asyncCheck connect(socket, serverAddr)

var messageFlowVar = spawn stdin.readLine()
...

This is in fact a slight bug in the implementation. The execution of the code will continue without waiting for the socket to be connected. But data will not be sent to the socket unless a line from stdin is read, so for most practical uses of this application it is not a problem.

The best way to solve this would be to use await, but in order to do that the code needs to be wrapped in an async procedure (as await is not allowed in the global scope).

Clone this wiki locally