Skip to content

Instantly share code, notes, and snippets.

@dom96
Created April 26, 2014 20:58
Show Gist options
  • Save dom96/6fe8c0675eb6f9e90509 to your computer and use it in GitHub Desktop.
Save dom96/6fe8c0675eb6f9e90509 to your computer and use it in GitHub Desktop.
proc safeRecvLine(sock: PAsyncSocket): PFuture[string] =
var retFut = newFuture[string]()
var recvLineFut = sock.recvLine()
recvLineFut.callback =
proc () =
if recvLineFut.failed:
retFut.complete("")
else:
retFut.complete(recvLineFut.read)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment