mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
test
This commit is contained in:
parent
c751e438f3
commit
073b35fdd6
2 changed files with 5 additions and 1 deletions
|
|
@ -7,7 +7,7 @@ for i = 1, 3 do
|
|||
srv:send(address, port, "pong")
|
||||
end)
|
||||
|
||||
network.udp_connect("0.0.0.0", 8645, function (data)
|
||||
network.udp_connect("localhost", 8645, function (data)
|
||||
print(string.format("client received %s byte(s) from server", #data))
|
||||
complete = true
|
||||
end, function (socket)
|
||||
|
|
|
|||
|
|
@ -711,9 +711,11 @@ public:
|
|||
}
|
||||
|
||||
int send(const char* buffer, size_t length) override {
|
||||
logger.info() << "SocketUdpConnection send " << length << " " << getAddress();
|
||||
int len = sendto(descriptor, buffer, length, 0,
|
||||
(sockaddr*)&addr, sizeof(addr));
|
||||
if (len < 0) {
|
||||
logger.info() << "SocketUdpConnection closed";
|
||||
closesocket(descriptor);
|
||||
state = ConnectionState::CLOSED;
|
||||
} else totalUpload += len;
|
||||
|
|
@ -786,9 +788,11 @@ public:
|
|||
sockaddr_in clientAddr{};
|
||||
socklen_t addrlen = sizeof(clientAddr);
|
||||
|
||||
logger.info() << "udp clients listener started " << open;
|
||||
while (open) {
|
||||
int size = recvfrom(descriptor, buffer.data(), buffer.size(), 0,
|
||||
reinterpret_cast<sockaddr*>(&clientAddr), &addrlen);
|
||||
logger.info() << "udp clients listener received " << size;
|
||||
if (size <= 0) {
|
||||
if (!open) break;
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue