This commit is contained in:
Jakub Adamski 2019-11-27 11:25:23 +01:00
parent 1039e80b3b
commit 28d0f2a2c5
6 changed files with 8 additions and 3 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
server/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -37,8 +37,8 @@ int main(void) {
int socket_recv;
int accept_recv;
int accept_temp;
char msg[1024] = "Puste";
char msg_copy[1024];
char msg[1025] = "Puste";
char msg_copy[1025];
struct client_socket client[7]; //Tablica Klientów
fd_set Socket; //Zbiór jednego deskryptora - głównego socketa
fd_set Recv;
@ -170,7 +170,7 @@ int main(void) {
client[i].accept_adr = accept_temp_adr;
FD_SET(client[i].socket, &client[i].Client);
printf("Dodano użytkownika %s na miejscu %i\n", inet_ntoa(client[i].accept_adr.sin_addr), i);
//strcpy(client[i].Ip, inet_ntoa(client[i].accept_adr.sin_addr));
strcpy(client[i].Ip, inet_ntoa(client[i].accept_adr.sin_addr));
i++;
break;
} else {
@ -188,6 +188,8 @@ int main(void) {
if(select(socket_recv+1, &Recv, NULL, NULL, &timeout) > 0) {
printf("Wykryto wiadomosc\n");
accept_recv = accept(socket_recv, (struct sockaddr*)&recv_adr, &dl);
memset(msg, 0, 1024);
memset(msg_copy, 0, 1024);
if(recv(accept_recv, msg, 1024, 0) > 0) {
//Sklonuj msg i tokenizuj trzy pierwsze słowa (1.user> 2.Down/upload 3.Sciezka do pliku)
printf("Zaczynam Kopiowac\n");
@ -218,6 +220,7 @@ int main(void) {
if(strcmp(client[i].Ip, inet_ntoa(recv_adr.sin_addr)) == 0) {
printf("Użytkownik %i wyszedł\n", i);
close(client[i].socket);
client[i].socket = 0;
}
i++;
}
@ -251,6 +254,7 @@ int main(void) {
break;
}
razem += send_plik;
memset(msg, 0, 1024);
}
fclose(plik);
@ -290,6 +294,7 @@ int main(void) {
break;
}
fwrite(msg, 1, 1024, plik);
memset(msg, 0, 1024);
razem += read_plik;
}
fclose(plik);

BIN
server/test.txt Normal file

Binary file not shown.

BIN
test.txt Normal file

Binary file not shown.

BIN
wordpress-5.1.1-pl_PL.zip Normal file

Binary file not shown.