[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: oftopic: (2) select()& O_NONBLOCK: new URL



On Sat, Jun 02, 2001 at 07:58:23PM +0700, Pavel Orehov wrote:
> > > Поступаю просто (http://oniltz.da.ru/~opa/test.c)
> > Достучаться не могу, поэтому буду говорить про написанное.
> http://www.nsib.ru/~opa/test.c
> http://land7.nsu.ru/~opa/test.c
>

Посмотрю через полчасика.

> и общий встречный вопрос: откуда (из какой строки мана) следует, что read
> вернет столько сколько уже есть и чем это его поведение отличается от
> случая O_NONBLOCK или я совсем тормоз? Вроде в блокирующем режиме он
> обязан стоять, пока не прочитает _ВСЕ_ запрошенное?
> 
> 

Нет. В блокирующем режиме read будет стоять, пока не прочтет хоть что-нибудь.

[17:05] dg@cloud:~$ man 2 read

...

RETURN VALUE
       On success, the number of bytes  read  is  returned  (zero
       indicates  end of file), and the file position is advanced
       by this number.  It is not an  error  if  this  number  is
       smaller  than the number of bytes requested; this may hap
       pen for example because fewer bytes are actually available
       right  now (maybe because we were close to end-of-file, or
       because we are reading from a pipe, or from  a  terminal),
       or  because read() was interrupted by a signal.  On error,
       -1 is returned, and errno is set  appropriately.  In  this
       case  it is left unspecified whether the file position (if
       any) changes.

...

ERRORS

...

       EAGAIN Non-blocking I/O has been selected using O_NONBLOCK
              and no data was immediately available for  reading.


-- 
dg



Reply to: