| | |
| | | fd_set rdset; |
| | | char buf[1024]; |
| | | int mode = 0; |
| | | char *rd_fifo = NULL; |
| | | char *wr_fifo = NULL; |
| | | |
| | | if( argc != 2 ) |
| | | { |
| | |
| | | } |
| | | |
| | | mode = atoi(argv[1]); |
| | | |
| | | if( 0 == mode ) |
| | | { |
| | | rd_fifo = FIFO_FILE1; |
| | | wr_fifo = FIFO_FILE2; |
| | | } |
| | | else |
| | | { |
| | | rd_fifo = FIFO_FILE2; |
| | | wr_fifo = FIFO_FILE1; |
| | | } |
| | | |
| | | if( access(FIFO_FILE1 , F_OK) ) |
| | | { |
| | |
| | | |
| | | if( 0 == mode ) |
| | | { |
| | | printf("start open '%s' for read and it will blocked untill write endpoint opened...\n", rd_fifo); |
| | | if( (fdr_fifo=open(rd_fifo, O_RDONLY)) < 0 ) |
| | | printf("start open '%s' for read and it will blocked untill write endpoint opened...\n", FIFO_FILE1); |
| | | if( (fdr_fifo=open(FIFO_FILE1, O_RDONLY)) < 0 ) |
| | | { |
| | | printf("Open fifo[%s] for chat read endpoint failure: %s\n", rd_fifo, strerror(errno)); |
| | | printf("Open fifo[%s] for chat read endpoint failure: %s\n", FIFO_FILE1, strerror(errno)); |
| | | return -1; |
| | | } |
| | | |
| | | printf("start open '%s' for write...\n", wr_fifo); |
| | | if( (fdw_fifo=open(wr_fifo, O_WRONLY)) < 0 ) |
| | | printf("start open '%s' for write...\n", FIFO_FILE2); |
| | | if( (fdw_fifo=open(FIFO_FILE2, O_WRONLY)) < 0 ) |
| | | { |
| | | printf("Open fifo[%s] for chat write endpoint failure: %s\n", wr_fifo, strerror(errno)); |
| | | printf("Open fifo[%s] for chat write endpoint failure: %s\n", FIFO_FILE2, strerror(errno)); |
| | | return -1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | printf("start open '%s' for write and it will blocked untill read endpoint opened...\n", wr_fifo); |
| | | if( (fdw_fifo=open(wr_fifo, O_WRONLY)) < 0 ) |
| | | printf("start open '%s' for write and it will blocked untill read endpoint opened...\n", FIFO_FILE1); |
| | | if( (fdw_fifo=open(FIFO_FILE1, O_WRONLY)) < 0 ) |
| | | { |
| | | printf("Open fifo[%s] for chat write endpoint failure: %s\n", wr_fifo, strerror(errno)); |
| | | printf("Open fifo[%s] for chat write endpoint failure: %s\n", FIFO_FILE1, strerror(errno)); |
| | | return -1; |
| | | } |
| | | |
| | | printf("start open '%s' for read...\n", rd_fifo); |
| | | if( (fdr_fifo=open(rd_fifo, O_RDONLY)) < 0 ) |
| | | printf("start open '%s' for read...\n", FIFO_FILE2); |
| | | if( (fdr_fifo=open(FIFO_FILE2, O_RDONLY)) < 0 ) |
| | | { |
| | | printf("Open fifo[%s] for chat read endpoint failure: %s\n", rd_fifo, strerror(errno)); |
| | | printf("Open fifo[%s] for chat read endpoint failure: %s\n", FIFO_FILE2, strerror(errno)); |
| | | return -1; |
| | | } |
| | | } |