Named Pipe Wrapper for Win32 Platforms
Background
Using pipes is not too complicated on WindowsNT platforms, but on Win9X it4s not that easy because named pipes are not supported.
The wrapper
"cPipe" is a C++ wrapper class encapsulating named pipes, providing a simple interface to create named pipes and to perform read/write operations. In addition an application-defined callback function, which is called by the framework if data is available, can be specified on creation ( the server side of the sample demonstrates the usage of the callback function ).
"cPipe" contains the following public methods, fully documented within the source.
|
Method |
Description |
|
Create |
Creates
and registers the neccessary pipe(s). |
|
Close |
Closes
the pipe(s). |
|
ReadPipe |
Performs
read operation on the pipe. |
|
WritePipe |
Performs
write operation on the pipe. |
|
GetLastError |
Returns
the latest cPipe error code. |
The sample
The sample provides two tiny applications to demonstrate IPC. For the server-side run "core.exe" and for the client-side run "client.exe". For demonstration the server side just mirrors the data sent by the client application. I tested the sample applications on the following platforms: Win98, NT 4.0, W2k.
Server

Client
Downloads
Download demo project - 40 KbDownload source - 6 Kb

Comments
One-To-Many connection
Posted by Legacy on 10/06/2003 12:00amOriginally posted by: Alon Weiss
I've modified the code a bit to be a 'chat' between the 'core' and the 'client'.
A very interesting thing i've seen is that when i run two 'clients' and type stuff on the 'core', every Nth message is received by the first 'client', and every other message is receieved by the second.
Is this normal? How can i modify the code so both clients can recieve the messages?
Thanks,
ReplyAlon Weiss.
Excellent ! thank you for your working !
Posted by Legacy on 06/05/2003 12:00amOriginally posted by: silentsky
thanks really !
good luck to you !
Replyand happiness to you forever !
Problem with MS Terminal Server
Posted by Legacy on 05/13/2002 12:00amOriginally posted by: Walter
ReplyGreat work
Posted by Legacy on 09/28/2001 12:00amOriginally posted by: Andrea De Nardis
Thank you very much, this is what exactly needed in order to start w/ my job.
ReplyWindows 95, single host vs. networked hosts, and general comments
Posted by Legacy on 08/04/2001 12:00amOriginally posted by: Marc Clifton
Windows 95 only supports client-side NAMED pipes. The code works under W95 because it uses anonymous pipes (which are actually given a unique name under NT), and because the server and client applications must reside on the same host. Using anonymous pipes, it is not possible (I think!) to create a server-client application on two hosts over a network.
This is a good solution to single host named pipes on W95, however I would like to see a bit more robustness in a couple areas: handling of pipe disconnect issues (for example, the server app terminates), threading on the pipe write so the writer doesn't have to wait for the reader to read the data, and read/write buffering (it seems like the buffering could be handled by the pipe class instead of by the app???). Supporting the more general solution of named pipes for NT/W2000 OS's would be great too, thus allowing for distributed hosts (perhaps the OS specific solutions could be derived classes of a general pipe class?)
ReplyExplanation of Implementation with Win95 Named Pipe
Posted by Legacy on 08/02/2001 12:00amOriginally posted by: Steven
If Win95 named pipes are not supported, how do you support them with this code?
Reply