Named pipe class in wxWidget?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri May 18, 2007 9:46 am

Named pipe class in wxWidget?

Post by GuiOm » Tue May 29, 2007 12:46 pm

I'm brand new in wxWidget programming.
I've been coding an application for a month with wxWidget without having too much trouble ... but a new requirement came for my soft :
my app will have to dial with a existing, tested, validated application on a named pipe.

I can't find anywhere something about named pipe programming with wxwidget.
Is it a lack of documentation or there is really no way to use named pipes with this API?
I'd like to avoid coding my application with windows default pipe library ... Indeed I chose wxWidget for Linux protability ...
(I'm using Visual 2005 on windows XP for the moment but this can change in a close future).
but I do not want to modify my second app to make it dialoging on a TCP/IP socket because the validation process is quite long and complex ...

I'm afraid I have to choose between two bad solutions:
- code pipes and make my app not portable ...
- use sockets and make modifications in the second app and entre in a heavy validation progress ...

well,... any help or idea will be very appreciated...
thanks in advance,


Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri May 18, 2007 9:46 am

Post by GuiOm » Tue May 29, 2007 1:38 pm

It seems that wxFile::GetKind() can return wxFILE_KIND_PIPE ..
I imagine I can open the pipe created in my other app ...

I'm gonna try this immediatly ...

but as there is no SetKind or kind parameter in the file constructor, how can I create a pipe?

thanks again in advance for taking time to answer me.

Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri May 18, 2007 9:46 am

Post by GuiOm » Thu May 31, 2007 3:15 pm

well ... it seems that anybody even tried to use named pipes ...

I could open the 2 pipes created in the application I don't want to modify.
One is for my App to send commands (I will call it CMD). The second s used my the other application to send acknolegments (ACK).

So I opened CMD in write mode (wxFile* myPipeCmd = new wxFile(); myPipeCmd->Open("pipe cmd name",wxFile::write); ) and ACK in read mode.

myPipeCmd->GetKind() return me wxFILE_KIND_PIPE. (so does myPipeAck->GetKind() ).
So all seems to be OK.

When I put data in myPipeCmd with the Write method, the second app gets it without problem.

I'm getting into trouble when the second app wants to write data in the pipe. this app is written in C and writes in the pipe using:

// Write ACKRC to Pipe
fSuccess = WriteFile( Pipe->hPipeInst,

where pipe is a pointer on
typedef struct {
HANDLE hPipeInst;
DWORD cbToWrite;
DWORD dwState;
bool fPendingIO;

pipe was open with CreateFile function from winbase.h ....

question :
* are windows base pipe compatible with wxFile ones?
* is there a special way to open the pipe for reading data on it (special parameter to wxFile::Open() ?)
* why wxFile pipe management can work in a way (wriitting) and not in the opposite one (reading) ...

I'm a bit lost ....
Any help is welcome...

Thank you.

Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri May 18, 2007 9:46 am

Post by GuiOm » Fri Jun 01, 2007 8:39 am

well, I put some debug logs in the C-App and GetLastError() return 109... that means broken pipe.

I don't understand ...
my wxWidget app open the pipe , IsOpened returns true, it is open in Read mode ...

I tried with wxFFile but it is worse.. I'm no longer able to send data to the C-App... write works well but nothing is retrieved at the other end of the pipe...

It looks like I will be forced to modify the C-App to use socket instead of pipe ...

Post Reply