Unix Programming - regarding Blocking I/O

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2007 > regarding Blocking I/O





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author regarding Blocking I/O
kris

2007-07-13, 7:23 am


Hi I just want to know is there any concept of blocking I/O in unix.

In what way this can be implemented while writing the applications.

William Pursell

2007-07-13, 1:22 pm

On Jul 13, 12:29 pm, kris <raghavakrishn...@gmail.com> wrote:
> Hi I just want to know is there any concept of blocking I/O in unix.


Yes.

> In what way this can be implemented while writing the applications.


By default, pretty much all I/O is blocking. If you want to
get non-blocking I/O, you have to set your file descriptor
non-blocking. If you do nothing and just use fread/fwrite,
they will block until completed. If you use read/write,
your writes will block, but your reads will return a short
count if no data is available.

David Schwartz

2007-07-16, 7:20 am

On Jul 13, 11:20 am, William Pursell <bill.purs...@gmail.com> wrote:

> By default, pretty much all I/O is blocking. If you want to
> get non-blocking I/O, you have to set your file descriptor
> non-blocking. If you do nothing and just use fread/fwrite,
> they will block until completed. If you use read/write,
> your writes will block, but your reads will return a short
> count if no data is available.


Your reads will return a short count if less data is available than
you asked for. They will block if no data is available, unless it is
clear that no data could ever become available.

The exception is reading from normal files. They will sort of block
and sort of not block. For example if you try to read past the end of
a local file, it will not block in case new data is appended. If you
try to read before the end of a remote file, it will block until all
the requested data is received.

DS

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com