summary refs log tree commit diff stats
path: root/examples/unix_socket/server.nim
diff options
context:
space:
mode:
Diffstat (limited to 'examples/unix_socket/server.nim')
-rw-r--r--examples/unix_socket/server.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/unix_socket/server.nim b/examples/unix_socket/server.nim
new file mode 100644
index 000000000..e798bbb48
--- /dev/null
+++ b/examples/unix_socket/server.nim
@@ -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()