Urgent: Asychronous I/O in Unix
Posted on 1998-11-11
Please tell me how to simulate asynchronous I/O in Unix.i.e
If I am using normal
fread( void *buffer, size_t size, size_t count, FILE *stream);
command in my program the calling Unix process will block until the transfer is complete.
In Win32 we have the option like this
BOOL ReadFile( HANDLE hFile, // handle of file to read
LPVOID lpBuffer, // address of buffer that receives data
DWORD nNumberOfBytesToRead, // number of bytes to read
// address of number of bytes read
// address of structure for data );
If lpoverlapped is not NULL then
Here the lpOverlapped will be filled up by windows with some internal status info & my process will not block.Instead it will execute instructions written next to point where i made call to this command.
After some time if I want to test the status of my I/O I can use
BOOL GetOverlappedResult( HANDLE hFile,
// handle of file, pipe, or communications device
// address of overlapped structure
// address of actual bytes count
// wait flag );
which will return the status of I/O.So I have no need to wait for I/O to complete.
Please give me ways to simulate similar Asynchronous activity in Unix.I do not think it should be impossible to simulate above two API's using unix API.
Please send me any source code examples if you can.
Please provide some discrete solution.
Thanking in advance..