This C++ Program demonstrate the use of pipes to pass a continuous stream of data between processes. It has four parts i.e.
Simple named pipe client that demonstrates the API calls needed to successfully develop a basic named pipe client application.
Overlapped Server demonstrates how to develop an advanced named pipe server that is capable of servicing 5 named pipe instances.
Simple named pipe server that demonstrates the API calls needed to successfully develop a basic named pipe server application.
Advanced named pipe server that is capable of servicing 5 named pipe instances.
Table of Contents
- Client Application – Named Client Pipe
- Overlapped Server – Advanced Named Pipe Server
- Simple Named Pipe Server
- Thread Server – Advanced Named Pipe Server
Client Application – Named Client Pipe
Filename: Overlap.cpp
This C++ program is a simple named pipe client that demonstrates the API calls needed to successfully develop a basic named pipe client application. When this application successfully connects to a named pipe, the message “This is a test” is written to the server.
There are four basic steps needed to implement a client:
- Wait for a Named Pipe instance to become available using the WaitNamedPipe() API function.
- Connect to the Named Pipe using the CreateFile() API function.
- Send data to or receive data from the server using the WriteFile() and ReadFile() API functions.
- Close the Named Pipe session using the CloseHandle() API functions.
Compile
Command Line Options:
None
Source Code:
Overlapped Server – Advanced Named Pipe Server
Filename: Overlap.cpp
This sample demonstrates how to develop an advanced named pipe server that is capable of servicing 5 named pipe instances. The application is an echo server where data is received from a client and echoed back to the client. All the pipe instances are serviced in the main application thread using Win32 overlapped I/O.
Compile:
cl -o overlap overlap.cpp
Command Line Options:
None
Source Code:
Simple Named Pipe Server
Filename: Server.cpp
This program is a simple named pipe server that demonstrates the API calls needed to successfully develop a basic named pipe server application. When this application receives a client connection, it reads the data from the pipe and reports the received message.
You need five basic steps to write a named pipe server:
- Create a named pipe instance handle using the CreateNamedPipe() API function.
- Listen for a client connection on a pipe instance using the ConnectNamedPipe() API function.
- Receive from and send data to the client using the ReadFile() and WriteFile() API functions.
- Close down the named pipe connection using the DisconnectNamedPipe() API function.
- Close the named pipe instance handle using the CloseHandle() API function.
Compile:
Command Line Options:
None
Source Code:
Thread Server – Advanced Named Pipe Server
Filename: Threads.cpp
This sample demonstrates how to develop an advanced named pipe server that is capable of servicing 5 named pipe instances. The application is an echo server where data is received from a client and echoed back to the client. All the pipe instances are serviced using threads.
Compile:
Command Line Options:

Discover the mind behind the innovations – Elon Musk by Walter Isaacson, now on Audible. Dive into the life of a visionary shaping our future!
View on Amazon
None