#include #include #include #include #include #include #include #include #include #include void sig_chld(int signo) { pid_t pid; int stat; while ((pid = waitpid(-1, &stat, WNOHANG)) > 0) printf("child %d terminated.\n", pid); return ; } /* this routine read n bytes */ int readn (int sock, char *msgp, unsigned msgsize) { int rlen; int temp; do { rlen = read(sock, msgp, msgsize); } while (rlen == -1 && errno == EINTR); if (rlen == 0) { /* connection closed */ return 0; } while (rlen 0) write(rec_sock, buf, num); } exit(0); } else { close(rec_sock); } } }