title: lua-socket: unix domain sockets?
body: <p>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 <a href="http://lua-users.org/lists/lua-l/2008-07/msg00460.html" rel="nofollow">this</a></p>
  
  <pre><code>-- 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
  </code></pre>
  
  <p>Problem is, when I try and <code>connect()</code> I get "no such file or directory" - how do I create that socket in the first place? <code>mkfifo /tmp/foo</code> 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?).</p>
  
  <p>Is there any minimal working example out there of using luasocket on a unix domain socket?</p>
  
  <p><strong>EDIT: from Paul's solution, here's a MWE if anyone's interested</strong></p>
  
  <pre><code>libsocket = require "socket"
  libunix = require "socket.unix"
  socket = assert(libunix())
  SOCKET="/tmp/socket"
  assert(socket:bind(SOCKET))
  assert(socket:listen())
  conn = assert(socket:accept())
  while 1 do
      data=assert(conn:receive())
      print("Got line: " .. data)
      conn:send("echo: " .. data .. "\n")
      if data == "." then conn:close() return end
  end
  </code></pre>