aboutsummaryrefslogtreecommitdiffstats
path: root/src/ips
diff options
context:
space:
mode:
Diffstat (limited to 'src/ips')
-rw-r--r--src/ips/serversocket.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ips/serversocket.nim b/src/ips/serversocket.nim
index b476320e..61b633a9 100644
--- a/src/ips/serversocket.nim
+++ b/src/ips/serversocket.nim
@@ -1,3 +1,4 @@
+import nativesockets
import net
import os
when defined(posix):
@@ -12,9 +13,11 @@ const SocketPathPrefix = "cha_sock_"
proc getSocketPath*(pid: Pid): string =
SocketDirectory / SocketPathPrefix & $pid
-proc initServerSocket*(buffered = true): ServerSocket =
+proc initServerSocket*(buffered = true, blocking = true): ServerSocket =
createDir(SocketDirectory)
result.sock = newSocket(Domain.AF_UNIX, SockType.SOCK_STREAM, Protocol.IPPROTO_IP, buffered)
+ if not blocking:
+ result.sock.getFd().setBlocking(false)
result.path = getSocketPath(getpid())
discard unlink(cstring(result.path))
bindUnix(result.sock, result.path)