Skip to content

Instantly share code, notes, and snippets.

@enthus1ast
Last active May 19, 2018 19:50
Show Gist options
  • Save enthus1ast/14016b538c0433c76287f83ea2309aa9 to your computer and use it in GitHub Desktop.
Save enthus1ast/14016b538c0433c76287f83ea2309aa9 to your computer and use it in GitHub Desktop.
import net # # https://nim-lang.org/docs/net.html
var socket = newSocket()
socket.bindAddr(Port(1234))
socket.listen()
var client = new Socket
var address = ""
while true:
socket.acceptAddr(client, address)
echo("Client connected from: ", address)
# Client connected from: 127.0.0.1
# btcp.nim(9) btcp
# net.nim(793) acceptAddr
# system.nim(3788) failedAssertImpl
# system.nim(3781) raiseAssert
# system.nim(2843) sysFatal
# Error: unhandled exception: int(client.fd) <= 0 Client socket needs to be initialised with `new`, not `newSocket`. [AssertionError]
# Error: execution of an external program failed: '/home/david/nimPlayground/btcp '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment