離弦之Ray

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            55 Posts :: 0 Stories :: 33 Comments :: 0 Trackbacks
          A FIFO is similar to a pipe. A FIFO is a one-way flow of data (First In First Out). FIFOs have a name, so unrelated processes can share the FIFO. FIFO is a named pipe.

          FIFO和PIPE基本差不多,但FIFO是命名的,一些沒有親緣關系的process能共享它。

          Normally, opening a FIFO for read or write, it blocks until another process opens it for write or read. Write and read必須一一對應。

          A read gets as much data as it requests or as much data as the FIFO has, whichever is less.

          A write to a FIFO is atomic, as long as the write does not exceed the capacity of the FIFO. The capacity is at least 4k.


          How to set flags.

          writefd = open (FIFO1, O_WRONLY|O_ONOBLOCK,0);

          但是pipe沒有open函數

          所以只能這樣設定

          flags= fcntl (fd, F_GETFL,0);

          flag|=O_NONBLOCK;

          fcntl =(fd,F_SETFL,flags);


          下面的表很重要,要看清下面的前提操作和當前操作,主要比較了Blocking和O_NONBLOCK條件下的區別

          Operation

          Existing opens of pipe or FIFO

          Blocking (default)

          O_NONBLOCK set

          Open FIFO for reading

          FIFO open for writing

          Returns OK

          Returns OK

          FIFO not open for writing

          Blocks until FIFO is opened for writing

          Returns OK

          Open FIFO for writing

          FIFO open for reading

          Returns OK

          Returns OK

          FIFO not open for reading

          Blocks until FIFO is opened for reading

          Returns an error of ENXIO

          Read empty pipe or FIFO

          Pipe or FIFO open for writing

          Blocked until there is data or the pipe or FIFO is closed for writing

          Return an error of EAGAIN

          Pipe or FIFO not open for writing

          Read returns 0 (EOF)

          Read return 0 (EOF)

          Write to pipe or FIFO

          Pipe or FIFO open for reading

          Return ok

          Return ok

          Pipe or FIFO is full

          Blocked until space is available, then write data

          Returns an error of EAGAIN

          Pipe or FIFO not open for reading

          SIGPIPE generated, write process terminated

          Returns an error of EPIPE



          posted on 2006-06-20 23:42 離弦之ray的技術天空 閱讀(284) 評論(0)  編輯  收藏 所屬分類: Linux&C

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 涿州市| 伊通| 长顺县| 乐陵市| 莆田市| 西乌珠穆沁旗| 乌恰县| 岑巩县| 嘉鱼县| 鸡泽县| 昆明市| 乌鲁木齐县| 辰溪县| 华宁县| 比如县| 绵竹市| 岢岚县| 玉环县| 延寿县| 通州区| 班戈县| 九江县| 巴马| 金塔县| 崇州市| 黄浦区| 搜索| 余庆县| 松原市| 弥勒县| 迁西县| 滁州市| 大渡口区| 虎林市| 柳江县| 崇文区| 通榆县| 延寿县| 岱山县| 商河县| 上犹县|