Subj : named pipe problem on linux To : comp.lang.c++,comp.os.linux From : richard Date : Mon Nov 01 2004 05:36 am I have a simple test to pass information from a client to a server using named pipe. what I really want is: when I type a line on the client, the server will output the line immediately. but to my surprise, I always have to terminate the client to get the server in action, i.e. prints out what I typed. anything I missed? I am compiling using gcc without any option. thanks, ---RICH --------------------- server --------------------- #include #include #include #include #include #define FIFO_FILE "MYFIFO" int main(void) { FILE *fp; char readbuf[80]; /* Create the FIFO if it does not exist */ umask(0); mknod(FIFO_FILE, S_IFIFO|0666, 0); while(1) { fp = fopen(FIFO_FILE, "r"); fgets(readbuf, 10, fp); printf("Received string: %s\n", readbuf); fclose(fp); } return(0); } ------- client ------- #include #include #define FIFO_FILE "MYFIFO" int main(int argc, char *argv[]) { FILE *fp; char str[20]; if((fp = fopen(FIFO_FILE, "w")) == NULL) { perror("fopen"); exit(1); } while( scanf("%s", str) != EOF ) { fputs(str, fp); fputs(str, stdout); } fclose(fp); return(0); } .