/* * chat_receive.c - receive a line from the remote process & print it * until other end closes connection * (based on echo.c) */ #include "csapp.h" void chat_receive(int connfd){ char* prompt = "they said: "; char buf[MAXLINE]; size_t n; rio_t rio; Rio_readinitb(&rio, connfd); while((n = Rio_readlineb(&rio, buf, MAXLINE)) != 0) { Fputs(prompt, stdout); Fputs(buf, stdout); } }