lua-socket: unix domain sockets?

I’m using lua-socket 3.0rc1.3 (that comes with Ubuntu Trusty) and lua 5.1. I’m trying to listen on a unix domain socket, and the only example code I can find is this

-- send stdin through unix socket
socket = require"socket"
socket.unix = require"socket.unix"
c = assert(socket.unix())
assert(c:connect("/tmp/foo"))
while 1 do
    local l = io.read()
    assert(c:send(l .. "n"))
end

Problem is, when I try and connect() I get “no such file or directory” – how do I create that socket in the first place? mkfifo /tmp/foo which someone recommended me gets me a “connection refused” error instead (I don’t think a fifo is the same thing as a domain socket?).

Is there any minimal working example out there of using luasocket on a unix domain socket?


Source: unix

Leave a Reply