close(fileno(stdin)); dup2(sockfd, fileno(stdin)); close(fileno(stdout)); dup2(sockfd, fileno(stdout)); close(fileno(stderr)); dup2(sockfd, fileno(stderr));