strecho02.c 262 B

123456789101112131415161718
  1. #include "unp.h"
  2. void
  3. str_echo(int sockfd)
  4. {
  5. ssize_t n;
  6. char line[MAXLINE];
  7. heartbeat_serv(sockfd, 1, 5);
  8. for ( ; ; ) {
  9. if ( (n = Readline(sockfd, line, MAXLINE)) == 0)
  10. return; /* connection closed by other end */
  11. Writen(sockfd, line, n);
  12. }
  13. }