diff options
author | Miran <narimiran@disroot.org> | 2019-01-22 16:06:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-22 16:06:44 +0100 |
commit | 0ebfcd4c0f6a5c287c23c188c28df242e2349747 (patch) | |
tree | a380516904b2caa944dcb0962be55874a975f79b /tests/async | |
parent | 54fecdb8dfa8a5721cb95b63cc8716283ee754d9 (diff) | |
download | Nim-0ebfcd4c0f6a5c287c23c188c28df242e2349747.tar.gz |
Remove deprecated modules (asyncio, sockets, ftpclient) (#10401)
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/tasyncawait.nim | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index fcb48a1f5..1e6cf3761 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -1,7 +1,7 @@ discard """ output: "5000" """ -import asyncdispatch, nativesockets, net, strutils, os +import asyncdispatch, asyncnet, nativesockets, net, strutils, os var msgCount = 0 @@ -12,20 +12,22 @@ const var clientCount = 0 proc sendMessages(client: AsyncFD) {.async.} = - for i in 0 .. <messagesToSend: + for i in 0 ..< messagesToSend: await send(client, "Message " & $i & "\c\L") proc launchSwarm(port: Port) {.async.} = - for i in 0 .. <swarmSize: - var sock = newAsyncNativeSocket() + for i in 0 ..< swarmSize: + var sock = createAsyncNativeSocket() await connect(sock, "localhost", port) await sendMessages(sock) closeSocket(sock) proc readMessages(client: AsyncFD) {.async.} = + # wrapping the AsyncFd into a AsyncSocket object + var sockObj = newAsyncSocket(client) while true: - var line = await recvLine(client) + var line = await recvLine(sockObj) if line == "": closeSocket(client) clientCount.inc @@ -37,7 +39,7 @@ proc readMessages(client: AsyncFD) {.async.} = doAssert false proc createServer(port: Port) {.async.} = - var server = newAsyncNativeSocket() + var server = createAsyncNativeSocket() block: var name: Sockaddr_in name.sin_family = toInt(AF_INET).uint16 |