blob: 177f2ef48d5ceeb15d38aab5be6402f48463e84a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import("core.base.bytes")
import("core.base.socket")
function main(addr)
addr = addr or path.join(os.tmpdir(), "echo.socket")
print("connect %s ..", addr)
local buff = bytes(8192)
local sock = socket.connect_unix(addr)
if sock then
print("%s: connected!", sock)
local count = 0
while count < 10000 do
local send = sock:send("hello world..", {block = true})
if send > 0 then
sock:recv(buff, 13, {block = true})
else
break
end
count = count + 1
end
print("%s: send ok, count: %d!", sock, count)
sock:close()
end
end
|