Upload files to "/"

This commit is contained in:
8nl 2024-02-27 10:59:19 +00:00
parent 698e5568ae
commit cfd57bdc67
1 changed files with 13 additions and 5 deletions

View File

@ -11,7 +11,7 @@
#define PORT 8888
#define BUFF_SIZE 2048
#define MAX_CLIENTS 10
#define MAX_CLIENTS 45
typedef struct {
int fd;
@ -41,6 +41,9 @@ int main(void) {
goto ERROR_WITHOUTCLOSE;
struct timeval tv = {.tv_sec = 1, .tv_usec = 0};
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
goto ERROR;
if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0)
goto ERROR;
@ -64,11 +67,16 @@ int main(void) {
int last = 0;
char buf[25];
socklen_t len = sizeof(data.clients[last]);
socklen_t len = sizeof(data.clients[0]);
while (1) {
if (recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&data.clients[last], &len) > 0)
if (last <= MAX_CLIENTS)
last++;
if (last <= MAX_CLIENTS) {
if (recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&data.clients[last], &len) > 0)
if (!strcmp(buf, "JOIN"))
last++;
}
else
last = 0;
}
ERROR: