/* * This is an example of using a named-pipe for uni-directional communication. * Client (./client) sends strings to the server (./server). You can run the two programs in separate terminals and observe the behavior. * For bi-directional communication, two uni-directional pipes should be used. * To compile: * * g++ named-pipe-client.cpp -o client * g++ named-pipe-server.cpp -o server */ #include #include #include #define FIFO_FILE "MYFIFO" using namespace std; int main(int argc, char *argv[]) { FILE *fp; string msg; while(1) { cin >> msg; char * cstr = (char*)msg.c_str(); fp = fopen(FIFO_FILE, "w"); fputs(cstr, fp); fclose(fp); } return(0); }