Click to See Complete Forum and Search --> : Asynchronous overlapped I/O


racette
November 14th, 2007, 10:57 AM
Hi gurus!

Im developping two softwares that need to communicate with each other over a network. The IPC mechanism we chose is the named pipes. Both softwares are being developped in C++.

When I did my preliminary tests, everything went fine but performance was not that good. I read that I needed to send and receive data asynchronously, which made sense to me.

So I changed everything to incorporate asynchronous overlapped I/O.

Here is what my softwares do:

Software A creates about a dozen named pipes.

Software B connects to those pipes.

Now, software A sends data through pipe #1. Pipe #1 was designed to send and receive blocks of 112 bytes. This data is received correctly by software B.

Up to here, everything is ok.

Then, software A sends data through pipe #2. Pipe #2 was designed to send and receive blocks of 153,268 bytes. This data is NOT received correctly by software B.

When I do my tests locally (on one pc running both softwares), this block of 153,268 bytes is sent and received correctly.

So my assumption is that there is something wrong with sending and receiving large blocks of data through named pipes over a network.

I read on different forums that there is a limit on the size of data that can be sent through named pipes over a network.

I tried everything I could find on the Internet, but didnt find anything that would work.

My questions are:

If a ReadFile or WriteFile call returns false, and that GetLastError() returns ERROR_IO_PENDING, what should I do to make sure the data is written or read entirely?

Should I call GetOverlappedResult()?

Does a call to GetOverlappedResult() keeps on reading or writing or should I call WriteFile or ReadFile again and again until its done?

Should I wait for the event that was specified to the Overlapped structure?

If someone asks, I can post the code I use.

Thanks.

MikeAThon
November 17th, 2007, 03:20 PM
I have only limited knowledge of named pipes, but since no one else is stepping up with an answer, here goes.

It's my understanding that named pipes are not as efficient as other forms of IPC when transferring large chunks of data. TCP/sockets, for example, are more efficient because of congestion control/sliding windows etc. However, even though they are not efficient, named pipes still work and work robustly.

For asynchronous operation, the proper response to a GetLastError() of ERROR_IO_PENDING, is to WaitForSingle/MultipleObject() on the event that you provided in the overlapped structure when initiating the pipe's operation. This event will become signalled when the operation completes.

One simple introduction to named pipes can be found at Dr. Dobbs Portal, "Better Pipes for Windows" by Bill Heyman, http://drdobbs.com/cpp/184403200?pgno=13 . Sample code is provided.

Mike