-
-
Save ftsf/304fd7c2b7f13825dbead0fd7459ffc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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