summary refs log tree commit diff stats
path: root/tests/async/tasyncsend4757.nim
blob: a87c5df9594a68072efb2d53af72c48cd6a7068a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
discard """
output: "Finished"
"""

import asyncdispatch, asyncnet

proc createServer(port: Port) {.async.} =
  var server = newAsyncSocket()
  server.setSockOpt(OptReuseAddr, true)
  bindAddr(server, port)
  server.listen()
  while true:
    let client = await server.accept()
    discard await client.recvLine()

asyncCheck createServer(10335.Port)

proc f(): Future[void] {.async.} =
  let s = newAsyncNativeSocket()
  await s.connect("localhost", 10335.Port)
  await s.send("123")
  echo "Finished"

waitFor f()