Create a gist now

Instantly share code, notes, and snippets.

@ftsf /client.nim Secret
Created Jan 12, 2017

import net
var socket = newSocket()
socket.connect("localhost",Port(9000))
type Foo = tuple[a,b,c,d: int]
var data: Foo = (a: 1, b: 2, c: 3, d: 4)
discard socket.send(data.addr, sizeof(Foo))
socket.close()
import net
var socket = newSocket()
socket.bindAddr(Port(9000))
socket.listen()
echo "server listening..."
type Foo = tuple[a,b,c,d: int]
var client = newSocket()
var address = ""
while true:
socket.acceptAddr(client, address)
echo "client connected from ", address
var data: Foo
discard client.recv(data.addr, sizeof(Foo))
echo data
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment