当前位置:网站首页>Read stream special attention

Read stream special attention

2022-06-22 03:55:00 Hongdayu

 If  read()  Not all the data in the message was retrieved , Then the remaining data should be left in  STREAM  in , And you can pass the next  read()  Call to retrieve . Information -
        Discard patterns also retrieve data , Until the requested number of bytes is transmitted , Or the message boundary is reached . However , Unread data remains in a 
       read()  The returned message will be discarded , And cannot be used for subsequent  read()getmsg()  or  getpmsg()  call .

       read()  How to handle zero bytes  STREAMS  The message is determined by the current read mode setting . In byte stream mode ,read()  Will accept data , Until it reads 
       nbyte  byte , Or until there is no more data to read , Or until a zero byte message block is encountered . then  read()  The number that the function should return 
        Number of bytes read , And put the zero byte message back  STREAM  On , For the next  read()getmsg()  or  getpmsg()  retrieval . In the message do not drop mode or message 
       sage-discard  Pattern , A zero byte message should return  0, And the message should be from  STREAM  Delete in . When a zero byte message is read as the first message 
        stay  STREAM  On , Regardless of the read mode , Should be  STREAM  Delete the message and return  0.

        come from  STREAMS  Of documents  read()  Should be in  STREAM  The header reads the data in the message returned from the front of the queue , Regardless of the priority band of the message .

        By default ,STREAM  In control normal mode , One is from  STREAMS  Of documents  read()  Can only process parts that contain data but do not contain 
        control section . If in  STREAM  The header encountered a message containing a control part ,read()  Will fail . This default action can be done by placing 
        Use  I_SRDOPT ioctl()  The command is executed in control data mode or control discard mode  STREAM. In control data mode ,read()  Any control part shall be converted to 
        Data and pass it to the application , Then pass any data parts that originally existed in the same message . In control discard mode ,read()  Message will be discarded 
        control section , But return any data part of the message to the process .

        Besides , If  STREAM  The header handled an asynchronous error before the call , be  read()  Will fail . under these circumstances ,errno  The value of should not reflect 
       read()  Result , But it reflects a previous mistake . If you are reading  STREAM  A hang occurred ,read()  Will continue to operate normally , until  STREAM  head 
        The read queue is empty . thereafter , It will return  0.

       pread()  The function should be equivalent to  read(), Except that it should read from a given location in the file without changing the file pointer . First 
       pread()  The three parameters of  read()  identical , Just add a fourth parameter offset for the desired location in the file . Trying to perform 
        Could not find... On file  pread()  Will lead to mistakes .

 Return value 
        After successful completion , These functions should return a nonnegative integer , Indicates the number of bytes actually read . otherwise , Function should 
        return  -1  And set up  errno  To indicate an error .
原网站

版权声明
本文为[Hongdayu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220342516482.html