net.nim: add support for Unix sockets

This commit is contained in:
Michał Zieliński
2015-10-28 19:55:04 +01:00
parent 8e4b5e10ba
commit da308be2d7
5 changed files with 57 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
import net
let sock = newSocket(AF_UNIX, SOCK_STREAM, IPPROTO_IP)
sock.connectUnix("sock")
sock.send("hello\n")

View File

@@ -0,0 +1,14 @@
import net
let sock = newSocket(AF_UNIX, SOCK_STREAM, IPPROTO_IP)
sock.bindUnix("sock")
sock.listen()
while true:
var client = new(Socket)
sock.accept(client)
var output = ""
output.setLen 32
client.readLine(output)
echo "got ", output
client.close()