|
- #include "unp.h"
- void
- str_cli(FILE *fp,int sockfd)
- {
- pid_t pid;
- char sendline[MAXLINE],recvline[MAXLINE];
- if((pid=fork())==0) { /* child : server -> stdout */
- while(Readline(sockfd,recvline,MAXLINE) >0)
- Fputs(recvline,stdout);
- kill(getpid(),SIGTERM); /* in case parent still running*/
- exit(0);
- }
- /* parent: stdin -> server */
- while(Fgets(sendline,MAXLINE,fp) != NULL )
- Writen(sockfd,sendline,strlen(sendline));
- Shutdown(sockfd,SHUT_WR); /* EOF on stdin,send FIN */
- pause();
- return;
- }
复制代码 kill() 和pause()的作用看不明白!!:thank |
|