Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncdispatch, asyncnet
- proc handleConnection(conn: AsyncSocket) {.async.} =
- # Print a message to the console
- echo("Received a connection from ", conn.peerAddr)
- # Close the connection
- conn.close()
- # Open a socket and listen on port 8080
- let listener = newAsyncListener(handleConnection, addr = "0.0.0.0"::IPv4, port = 8080)
- # Print a message to the console
- echo("Listening on port 8080...")
- # Wait for connections to be received
- await listener.waitForConnections()
Advertisement
Add Comment
Please, Sign In to add comment