不过我还是建议你用 {.async.} , 省不少事情,性能其实损失不了多少:
    
    
    import asyncnet, asyncdispatch
    
    proc recvAll(sock: AsyncSocket) {.async.} =
      for i in 0 .. 50:
        var ret = await recv(sock, 10)
        echo("Read ", ret.len, ": ", ret.repr)
    
    proc main() {.async.} =
      var sock = newAsyncSocket()
      await sock.connect("irc.freenode.net", Port(6667))
      await sock.recvAll()
    
    waitFor main()
    

Reply via email to