A question on mailslot
From: cyberninja (cyberninja_at_discussions.microsoft.com)
Date: 06/10/04
- Next message: Stanley Feng \(MSFT\): "Re: IOCP or loop forever?"
- Previous message: Eric: "Re: 802.11b: search the network"
- Next in thread: R.Wieser: "Re: A question on mailslot"
- Reply: R.Wieser: "Re: A question on mailslot"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Jun 2004 16:29:01 -0700
When reading a stream from a mailslot, the following Win32 API is used:
BOOL ReadFile(HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
However, there are some difference between calling ReadFile for a disk file and for a mailslot stream. If hFile is a handle for the a mailslot, if the param of "nNumberOfBytesToRead" is less than the total message size (you can retrieve it from GetMailslotInfo()), nothing will be read and *lpNumberOfBytesRead will be 0.
This situation raise a problem: if *lpNumberOfBytesRead is less than nNumberOfBytesToRead, what can we do except return an error? As you know, in file stream, you still get something and *lpNumberOfBytesRead will not be 0, so you can continue reading the handle in a loop until all data are read. In mailslot stream, if you do so, in the next loop you still get 0 in *lpNumberOfBytesRead.
Any suggestion for handling this situation?
Thanks
- Next message: Stanley Feng \(MSFT\): "Re: IOCP or loop forever?"
- Previous message: Eric: "Re: 802.11b: search the network"
- Next in thread: R.Wieser: "Re: A question on mailslot"
- Reply: R.Wieser: "Re: A question on mailslot"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|