Dont use asyncCheck

This commit is contained in:
Yuriy Glukhov 2018-05-11 13:11:57 +03:00
parent e7959ee19d
commit e53daf31f7
1 changed files with 3 additions and 2 deletions

View File

@ -31,6 +31,7 @@ proc receiveHandshake(s: Server, address: string, remote: AsyncSocket) {.async.}
echo "Could not establish connection with incoming peer" echo "Could not establish connection with incoming peer"
proc run(s: Server) {.async.} = proc run(s: Server) {.async.} =
# TODO: Add error handling
s.socket = newAsyncSocket() s.socket = newAsyncSocket()
s.socket.setSockOpt(OptReuseAddr, true) s.socket.setSockOpt(OptReuseAddr, true)
s.socket.bindAddr(s.address.tcpPort) s.socket.bindAddr(s.address.tcpPort)
@ -38,11 +39,11 @@ proc run(s: Server) {.async.} =
while s.isRunning: while s.isRunning:
let (address, client) = await s.socket.acceptAddr() let (address, client) = await s.socket.acceptAddr()
asyncCheck s.receiveHandshake(address, client) discard s.receiveHandshake(address, client)
proc start*(s: Server) = proc start*(s: Server) =
if not s.isRunning: if not s.isRunning:
asyncCheck s.run() discard s.run()
proc stop*(s: Server) = proc stop*(s: Server) =
if s.isRunning: if s.isRunning: