// This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include "include/client.h" int main(int argc, char *argv[]) { int fd; if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) printSystemError("User: socket()"); struct sockaddr_in serv_addr; setSockAddress(argc, argv, &serv_addr); if (connect(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) printSystemError("User: connect()"); char input[MAX_LEN] = {0}; int readChars; while ((readChars = read(STDIN_FILENO, input, MAX_LEN - 1)) != 0) { if (readChars < 0) printSystemError("User: read()"); input[readChars] = '\0'; if (write(fd, input, readChars) < 0) printSystemError("User: write()"); } close(fd); return EXIT_SUCCESS; }