#include "include/client.h" int main(int argc, char *argv[]) { int fd = 0; struct sockaddr_in serv_addr; if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printSystemError("User: socket()"); } serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); serv_addr.sin_addr.s_addr = inet_addr(ADDRESS); 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; }