0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-27 04:43:52 +01:00
This commit is contained in:
2025-12-24 22:26:54 +01:00
parent 39b80e113c
commit 04a7687cdd
7 changed files with 18 additions and 34 deletions

View File

@@ -39,14 +39,13 @@ void poll_udp_server() {
static char buf[BUF_SIZE];
static char cmd_buf[BUF_SIZE];
static char cmd_output[BUF_SIZE];
ssize_t bytes_read;
if (poll(&poller, 1, UDP_READ_TIMEOUT_MS) <= 0) return;
if (!(poller.revents & POLLIN)) return;
memset(buf, 0, BUF_SIZE);
client_len = sizeof(client_addr);
bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
ssize_t bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
if (bytes_read <= 0) return;
buf[bytes_read] = '\0';
@@ -62,10 +61,7 @@ void poll_udp_server() {
run_lua(cmd_buf, cmd_output);
size_t out_len = strlen(cmd_output);
if (out_len > 0) {
ssize_t sent = sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len);
if (sent == -1) perror("sendto");
}
if (out_len > 0 && sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len) == -1) perror("sendto"); // no walrus
}
token = strtok(NULL, "\r\n");
}