import strutils, net, unittest import ../asyncdispatch2 const ClientsCount = 2 MessagesCount = 1000 proc serveClient1(transp: StreamTransport, udata: pointer) {.async.} = echo "SERVER STARTING (0x" & toHex[uint](cast[uint](transp)) & ")" while not transp.atEof(): var data = await transp.readLine() echo "SERVER READ [" & data & "]" if data.startsWith("REQUEST"): var numstr = data[7..^1] var num = parseInt(numstr) var ans = "ANSWER" & $num & "\r\n" var res = await transp.write(cast[pointer](addr ans[0]), len(ans)) # doAssert(res == len(ans)) echo "SERVER EXITING (0x" & toHex[uint](cast[uint](transp)) & ")" proc swarmWorker(address: TransportAddress) {.async.} = echo "CONNECTING TO " & $address var transp = await connect(address) echo "CONNECTED" for i in 0..