AsyncRead

Reads a file directly from cache memory

Local Servers:blocking
Remote Servers:N/A
Classification:3.x, 4.x, 5.x, 6.x
Service:Advanced

Syntax

  #include <nwfileio.h>  
   
  int AsyncRead  (  
     int                        handle,   
     LONG                       startingOffset,   
     LONG                       numberOfBytesToRead,   
     LONG                      *numberOfBytesActuallyRead,   
     LONG                       localSemaphoreHandle,   
     T_cacheBufferStructure   **cacheBufferInformation,   
     LONG                      *numberOfCacheBuffers); 
  

Parameters

handle

(IN) Specifies a handle of the file from which data is to be read.

startingOffset

(IN) Specifies the offset in the file from which the first byte is to be read.

numberOfBytesToRead

(IN) Specifies the number of bytes to read from the file.

numberOfBytesActuallyRead

(OUT) Points to the number of bytes actually read from the file.

localSemaphoreHandle

(IN) Specifies this is used by the AsyncRead Event Service Routine (ESR) to signal completion of all of the requested cache reads for a particular call to AsyncRead. A local semaphore handle is obtained by calling OpenLocalSemaphore. Either WaitOnLocalSemaphore or ExamineLocalSemaphore should be used to determine when the ESR has signalled the semaphore.

cacheBufferInformation

(OUT) Points to an array of structures which contain the cache buffer pointers, lengths, and completion codes.

numberOfCacheBuffers

(OUT) Points to the number of cache buffers required to perform the file read.

Return Values

This function returns a value of 0 if successful. Otherwise, it returns an error code (nonzero value).

NOTE:If this function returns an error, do not wait on the local semaphore passed. AsyncRead does not signal the semaphore when the function fails.

Remarks

This function reads data from a file and returns pointers to the cache buffers which contain the requested data. The requested data can then be read directly from the cache buffers.

AsyncRead now reads only 64K at a time.

The cache buffer structure has the following form:

  typedef struct cacheBufferStructure  
     {  
     char    *cacheBufferPointer;  
     LONG    cacheBufferLength;  
     int     completionCode;  
     } T_cacheBufferStructure; 
  

The cacheBufferPointer field is the address of the first character for that particular cache buffer. The cacheBufferLength field is the number of bytes to be used from that cache buffer. The completionCode field is the NetWare error code for that particular cache buffer read operation.

AsyncRelease must be called to release the memory allocated by AsyncRead.

See Also

AsyncRelease, GetNLMHandle, OpenLocalSemaphore, WaitOnLocalSemaphore (NDK: NLM Threads Management)