|
Anonymous Pipes
An anonymous pipe is an unnamed, one-way pipe that transfers data between a parent process and
a child process or between two child processes of the same parent process.
Although it is possible to use anonymous pipes for communication between unrelated
processes, it is easier to use named pipes for that purpose (for more
information, see Named Pipes). Anonymous pipes are always local; they cannot be used for communication
over a network.
The CreatePipe function creates an anonymous pipe and returns two handles, one to the read
end and one to the write end of the pipe. The read handle has only read access
to the pipe, and the write handle has only write access to the pipe. To
communicate through the pipe, a handle to one of the ends must be passed to another
process. Usually, this is done through inheritance; that is, a child process
inherits a handle from its parent process. The inheritability of these handles is
controlled by the creating process in the following ways:
- The CreatePipe function specifies a SECURITY_ATTRIBUTES structure. If the bInheritHandle member of this structure is TRUE, the handles can be inherited.
- The DuplicateHandle function can change the inheritability of a pipe handle. This function
enables a process to create a noninheritable duplicate of an inheritable pipe handle
or to create an inheritable duplicate of a noninheritable pipe handle.
- The CreateProcess function enables a parent process to specify whether the new child process
will inherit all or none of the parent's inheritable handles.
When a child process inherits a handle, the system enables the process to
access the pipe referred to by that handle. However, the parent process must
communicate the handle value to the child process. Typically, this is done by using
the SetStdHandle and GetStdHandle functions, which set and retrieve the standard handles (standard input,
standard output, or standard error) of a process. The parent process can specify a
pipe handle in a call to SetStdHandle before the child process is created. The current standard handles of the
parent process are inherited by the child process. So, when the child process
starts up, it can use the GetStdHandle function to retrieve the handle value. The parent process can change its own
standard handles without affecting the standard handles of its existing child
processes.
To read from the pipe, a process uses the read handle in a call to the ReadFile function. When a write operation of any number of bytes completes, the ReadFile call returns. The ReadFile call also returns when all handles to the write end of the pipe have been
closed or if any errors occur before the read operation completes normally.
To write to the pipe, a process uses the write handle in a call to the WriteFile function. WriteFile does not return until the specified number of bytes has been written or an
error occurs. If the pipe's buffer is full and bytes remain to be written, WriteFile does not return until some other process or thread reads from the pipe,
making more buffer space available. CreatePipe enables the creating process to specify a buffer size for the pipe, or it can
use the default buffer size.
Asynchronous (overlapped) read and write operations are not supported for
anonymous pipes. This means that the ReadFileEx and WriteFileEx functions cannot be used with anonymous pipes. The lpOverLapped parameter of the ReadFile and WriteFile functions is ignored when used with an anonymous pipe.
An anonymous pipe exists until all handles to both read and write ends of the
pipe are closed by the CloseHandle function.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|