#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { if (argc < 2) { printf("Requires atleast 1 argument!\n"); return -1; } const char *server_name = "127.0.0.1"; int sockfd, connfd; struct sockaddr_in servaddr, cli; sockfd = socket(AF_INET, SOCK_STREAM, 0); servaddr.sin_family = AF_INET; inet_pton(AF_INET, server_name, &servaddr.sin_addr); int port = 0; printf("Enter port to connect to: "); scanf("%d", &port); fflush(stdout); fflush(stdin); servaddr.sin_port = htons(port); connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)); printf("Connected to server!\n"); fflush(stdout); char file_contents[100]; send(sockfd, argv[1], strlen(argv[1]), 0); int cont; while((cont=(recv(sockfd, file_contents, 100, 0))) > 0) { printf("File contents: %s", file_contents); } close(sockfd); }