mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
update
This commit is contained in:
parent
42253e2493
commit
95c1ca168d
2 changed files with 9 additions and 6 deletions
|
|
@ -1,27 +1,28 @@
|
||||||
|
math.randomseed(43172)
|
||||||
for i = 1, 15 do
|
for i = 1, 15 do
|
||||||
print(string.format("iteration %s", i))
|
debug.print(string.format("iteration %s", i))
|
||||||
local complete = false
|
local complete = false
|
||||||
|
|
||||||
local server = network.udp_open(8645 + i, function (address, port, data, srv)
|
local server = network.udp_open(8645 + i, function (address, port, data, srv)
|
||||||
print(string.format("server received %s byte(s) from %s:%s", #data, address, port))
|
debug.print(string.format("server received %s byte(s) from %s:%s", #data, address, port))
|
||||||
srv:send(address, port, "pong")
|
srv:send(address, port, "pong")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
app.tick()
|
app.tick()
|
||||||
network.udp_connect("localhost", 8645 + i, function (data)
|
network.udp_connect("localhost", 8645 + i, function (data)
|
||||||
print(string.format("client received %s byte(s) from server", #data))
|
debug.print(string.format("client received %s byte(s) from server", #data))
|
||||||
complete = true
|
complete = true
|
||||||
end, function (socket)
|
end, function (socket)
|
||||||
print("udp socket opened")
|
debug.print("udp socket opened")
|
||||||
start_coroutine(function()
|
start_coroutine(function()
|
||||||
print("udp data-sender started")
|
debug.print("udp data-sender started")
|
||||||
for k = 1, 15 do
|
for k = 1, 15 do
|
||||||
local payload = ""
|
local payload = ""
|
||||||
for j = 1, 16 do
|
for j = 1, 16 do
|
||||||
payload = payload .. math.random(0, 9)
|
payload = payload .. math.random(0, 9)
|
||||||
end
|
end
|
||||||
socket:send(payload)
|
socket:send(payload)
|
||||||
print(string.format("sent packet %s (%s bytes)", k, #payload))
|
debug.print(string.format("sent packet %s (%s bytes)", k, #payload))
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
socket:close()
|
socket:close()
|
||||||
|
|
|
||||||
|
|
@ -695,7 +695,9 @@ public:
|
||||||
thread = std::make_unique<std::thread>([this]() {
|
thread = std::make_unique<std::thread>([this]() {
|
||||||
util::Buffer<char> buffer(16'384);
|
util::Buffer<char> buffer(16'384);
|
||||||
while (open) {
|
while (open) {
|
||||||
|
logger.info() << "SocketUdpConnection listening";
|
||||||
int size = recv(descriptor, buffer.data(), buffer.size(), 0);
|
int size = recv(descriptor, buffer.data(), buffer.size(), 0);
|
||||||
|
logger.info() << "SocketUdpConnection received " << size;
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
if (!open) break;
|
if (!open) break;
|
||||||
closesocket(descriptor);
|
closesocket(descriptor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue