Upload files to "/"
This commit is contained in:
parent
698e5568ae
commit
cfd57bdc67
18
server.c
18
server.c
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user