add simple tcp test
This commit is contained in:
parent
5de8ae5f61
commit
51859c1501
19
dev/tests/network.lua
Normal file
19
dev/tests/network.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
local data = "hello, world"
|
||||||
|
local complete = false
|
||||||
|
|
||||||
|
network.tcp_open(7645, function (client)
|
||||||
|
start_coroutine(function()
|
||||||
|
local received = client:recv(1024)
|
||||||
|
if received then
|
||||||
|
assert (data, utf8.tostring(received))
|
||||||
|
complete = true
|
||||||
|
end
|
||||||
|
coroutine.yield()
|
||||||
|
end, "client-listener")
|
||||||
|
end)
|
||||||
|
|
||||||
|
network.tcp_connect("localhost", 7645, function (socket)
|
||||||
|
socket:send(data)
|
||||||
|
end)
|
||||||
|
|
||||||
|
app.sleep_until(function () return complete end)
|
||||||
Loading…
x
Reference in New Issue
Block a user