Asynchronous I/O functions on CE

Hi,
I need to port a Windows desktop communication DLL to a PocketPC target. Unfortunately, it seems that CE doesn't support aynchronous call for the I/O function ReadFile, WriteFile and CreateFile but these functions were esential to my DLL.
So, is there really no support for overlapped I/O methods on CE ?
Is there another way to implement non-blocking read/write operations on serial ports or sockets ?
Thx, Negyoshi.
[448 byte] By [Negyoshi] at [2008-2-14]
# 1
Negyoshi,
There is no support for overlapped I/O. But Windows CE has non-blocking I/O. You can just use a ReadFile that will wait forever for a read and still use WriteFile. The read will not block the write.
I use it with serial ports and work perfectly. My program run on XP and CE and the CE code is much simpler and easier to implement.
I am starting to implement the socket now, but there is no reason to think that it would not work.
RMJR
RMarceloJR at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 2
Oh, I forgot to tell what is needed.
What I do , and I think everybody that need asynchronos i/o on CE, is to have a thread to read and use another to write.
In my case, I have a thread that sits over there on a readfile forever, and I use writefile on my main thread.
RMJR
RMarceloJR at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 3
Thx, i think I'll have to use this method, even though overlapped operations seemed to be much more efficient. The fact is, my DLL implements a communication protocol, so a lot of read/write operations must be called in a short time.
Do you use message queues ? Using WriteFile in your main thread is not blocking it ?
Could you share your code, i would like to have a look at your architecture, since you said it to work perfectly :)
Thx !
Negyoshi at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 4
Overlapped is more efficient, and should take some space too. That should be the reason why MS did not implement on CE. But that discussion is not the topic.
> Do you use message queues ?
I do not use message queues in that area of the code.
>Using WriteFile in your main thread is not blocking it ?
For example, I have a thread that is waiting on a char to arrive on the serial port. So, I have a read waiting for a byte without time-out. This Readfile blocks this thread, but it does not block the serial port. So, if you use a Writefile, this will block your thread. If you need to do something else, you should do it in another thread.
Unfortunetly, I cannot share the code because it is not mine.
You should read the book Programming Windows CE .NET Third editon. From Douglas Boling. Chapter 12. Very nice book.
RMJR
RMarceloJR at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...