Re: WriteFile()
- From: "Hector Santos" <nospamhere@xxxxxxxxxxxxxx>
- Date: Tue, 12 Apr 2005 16:50:23 -0400
> These two statements contradict with your original statement that
> '"synchronous operation" [...] implies block with no timeouts'.
I don't think so. I think I have been very consistent. Synchronous means
BLOCK call with no timeouts. A block call with timeout considerations is in
effect a "poor man's async" concept. In effect, it simulates concurrency.
> 'request = written' can be binary if only one byte is involved. If there
are
> more data, it depends on the medium. For serial ports and sockets, to name
> just two, it can be less than the entire data size. This is not Windows
> specific.
But again, and again and again, if you prepare the sync device, including
serial and sockets, for no timeouts, you will get a BLOCK.
On a READ, you will block 100%
On a WRITE, you will get SUCCESS or ERROR
Where is the timeout if I turned it off?
If I say READ and WRITE X bytes why will the system ignore the request
without an error?
> > I don't know how much simple it can get or why this is even a question.
>
> It is not. The concept is much older than WriteFile(). Have a look at
> _write(). As far as I can tell, it has not changed much since 1972 when
what
> later became known as the C Standard Library was created. And it may also
> complete _successfully_ upon writing _less_ than requested.
It depends on the platform. _write() will write what it can by the very
nature and purity of the function but depending on the platform and/or
device it will return an error.
Again, is is how you apply the design. You have to know the enviroment. A
write is a write. Under DOS, it will write what it can with the remaining
space, but FAIL if there is no space. Under Windows, _write uses
WriteFile(). It will ALWAYS return an error for a sync, no timeout device.
Just read with Windows _write docs says()
_write()
Return Value
If successful, _write returns the number of bytes actually written. If the
actual space remaining on the disk is less than the size of the buffer the
function is trying to write to the disk, _write fails and does not flush any
of the buffer’s contents to the disk. A return value of –1 indicates an
error. In this case, errno is set to one of two values: EBADF, which means
the file handle is invalid or the file is not opened for writing, or ENOSPC,
which means there is not enough space left on the device for the operation.
--
Hector Santos, Santronics Software, Inc.
http://www.santronics.com
.
- Follow-Ups:
- Re: WriteFile()
- From: Slava M. Usov
- Re: WriteFile()
- References:
- WriteFile()
- From: Frank A. Uepping
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Gary Chanson
- Re: WriteFile()
- From: Chris Burnette
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Chris Burnette
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Alexander Grigoriev
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Slava M. Usov
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Slava M. Usov
- WriteFile()
- Prev by Date: Re: 64 Bit XP and other OS
- Next by Date: Re: Two threads reading from same file?
- Previous by thread: Re: WriteFile()
- Next by thread: Re: WriteFile()
- Index(es):
Relevant Pages
|
Loading