Remove deprecated modules (asyncio, sockets, ftpclient) (#10401)

This commit is contained in:
Miran 2019-01-22 16:06:44 +01:00 • committed by GitHub
commit 0ebfcd4c0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 61 additions and 3187 deletions

View file

@ -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