#include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char odbior[10]; struct sockaddr_in endpoint; int sdsocket, addrlen, sdconnection; const int port = 7332; const char ip[512] = "192.168.0.43"; char buff[512]; char eee[1]; struct dirent **namelist; int n; char wiadomosc[512]; char mess[512]; endpoint.sin_family = AF_INET; endpoint.sin_port = htons(port); endpoint.sin_addr.s_addr = inet_addr(ip); addrlen = sizeof(struct sockaddr_in); while (1) { start: printf("Wpisz zapytanie do serwera\n"); scanf("%s", buff); if (strncmp("CLIENTOFF", buff, 9) == 0) { close(sdsocket); return 0; } else if (strncmp("HELP", buff, 4) == 0) { printf("COMMAND LIST:\n CLIENTOFF\n EXIT\n GET_ALL_FILES\n"); goto start; } if ((sdsocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("socket() nie powiodl sie (failed)\n"); return 1; } if (connect(sdsocket, (struct sockaddr *)&endpoint, addrlen) < 0) { printf("connect() nie powiodl sie (failed)\n"); return 0; } else printf("CONNECTED\n"); send(sdsocket, buff, 512, 0); close(sdsocket); if ((sdsocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("socket() nie powiodl sie (failed)\n"); return 1; } if (connect(sdsocket, (struct sockaddr *)&endpoint, addrlen) < 0) { printf("connect() nie powiodl sie (failed)\n"); return 0; } bzero(odbior, 512); recv(sdsocket, odbior, 512, 0); printf("%s\n", odbior); } return 0; }