rendered paste body#include <stdlib.h>#include <stdio.h>#include <stdint.h>#include <string.h>#include <sys/socket.h>#include <sys/select.h>#include <sys/types.h>#include <netdb.h>#include <unistd.h>int main(){ int sd, ret; char *line = NULL; size_t buflen = 0; int nread; if (-1 != (sd = socket(AF_INET, SOCK_STREAM, 0))) { struct addrinfo* addr = NULL, hints = {}; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; if (0 == (ret =getaddrinfo("localhost", "9090", &hints, &addr))) { if (0 == connect(sd, addr->ai_addr, addr->ai_addrlen)) { while (0 < (nread = getline(&line, &buflen, stdin))) { nread--; line[nread] = '\0'; if (0 == strcmp(line, "quit")) break; send(sd, line, nread, 0); } } else perror("connect: "); freeaddrinfo(addr); } else printf("gai: %s\n", gai_strerror(ret)); close(sd); } else perror("socket: "); return 0;}