support datagram unix domain sockets
This commit is contained in:
parent
30a64c585a
commit
aa1b8cc9bc
10 changed files with 803 additions and 316 deletions
|
@ -1,6 +1,6 @@
|
|||
socket = require"socket"
|
||||
socket.unix = require"socket.unix"
|
||||
c = assert(socket.unix())
|
||||
c = assert(socket.unix.tcp())
|
||||
assert(c:connect("/tmp/foo"))
|
||||
while 1 do
|
||||
local l = io.read()
|
|
@ -1,6 +1,6 @@
|
|||
socket = require"socket"
|
||||
socket.unix = require"socket.unix"
|
||||
u = assert(socket.unix())
|
||||
u = assert(socket.unix.tcp())
|
||||
assert(u:bind("/tmp/foo"))
|
||||
assert(u:listen())
|
||||
c = assert(u:accept())
|
9
test/unixudpclnt.lua
Normal file
9
test/unixudpclnt.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
socket = require"socket"
|
||||
socket.unix = require"socket.unix"
|
||||
c = assert(socket.unix.udp())
|
||||
c:bind("/tmp/bar")
|
||||
while 1 do
|
||||
local l = io.read("*l")
|
||||
assert(c:sendto(l, "/tmp/foo"))
|
||||
print(assert(c:receivefrom()))
|
||||
end
|
9
test/unixudpsrvr.lua
Normal file
9
test/unixudpsrvr.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
socket = require"socket"
|
||||
socket.unix = require"socket.unix"
|
||||
u = assert(socket.unix.udp())
|
||||
assert(u:bind("/tmp/foo"))
|
||||
while 1 do
|
||||
x, r = assert(u:receivefrom())
|
||||
print(x, r)
|
||||
assert(u:sendto(">" .. x, r))
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue