Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created April 22, 2024 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogaiu/2f11d48950a0fc9b210ffcb1bbb2197f to your computer and use it in GitHub Desktop.
Save sogaiu/2f11d48950a0fc9b210ffcb1bbb2197f to your computer and use it in GitHub Desktop.
janet unix domain socket
# one terminal
$ janet
Janet 1.34.0-c01b32c4 linux/x64/gcc - '(doc)' for help
repl:1:> (def s (net/listen :unix "ptus" :datagram))
<core/stream 0x55DAD743F760>
repl:2:> (def buf @"")
@""
repl:3:> (def who (:recv-from s 1024 buf))
<core/socket-address 0x55DAD7442020>
repl:4:> (pp buf)
@"hello"
nil
# another terminal
$ janet
Janet 1.34.0-c01b32c4 linux/x64/gcc - '(doc)' for help
repl:1:> (def c (net/connect :unix "ptus" :datagram))
<core/stream 0x5618F5BA4830>
repl:2:> (net/write c "hello")
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment