Board index » cppbuilder » Named pipes make me crazy
Named pipes make me crazy
2007-10-29 04:24:23 PM
I've been experiencing a problem with named pipes server (single
threaded server using i/o overlapped reading/writing). The code
examples of a client and server may be found in Codegear RAd
studio 2007 ("named pipe client" and "named pipes single thread
using overlapped i/o"). The only thing i changed was implementing
a reading handler wich was supposed to store received data into
the Tlist object.
The problem is that if i dont receive data from client outright
after connect i get an ERROR_IO_PENDING pseude error while executing ReadFile function. Subsequently, after having received
that error just once i'm unable to read the info from the pipe
unless to drop the client and try the same again (which results
with the same error).
Have no idea about whether was it planned by example writers to handle this kind of a trouble but nothing seems to be working to receive the data which followed that error.
So i'm interested is there any workarounds on that? I mean when i execute ReadFile and it returs ERROR_IO_PENDING error.
In my opinion the most common "reading pipe scenario" would be:
0)Connect to the client
1)Perform ReadFile on the connected pipe;
2)if it returns ERROR_IO_PENDING - wait for the pipe to finish the pending operation (read in this case) by using GetOverlappedResult function (as it implemented in example).
3) perform readfile function again.
The problem is that it can never read the data from the pipe later on even after all the info have been received (GetOverlappedResult returns correct bytes transferred).
As far as it goes i'm deeply stuck into that without seeing any light in the end of the tonnel.
Thanks in advance
Any help would be appreciated.
P.S. code examples located in CodeGear RAD Studion 2007 ("Using Pipes") ms-help://borland.bds5/Ipc/base/using_pipes.htm