Description |
Parent class: XIO
XPipe is a class which provides data-communication between related processes.
Therefore you redirect stdin/stdout/stderr to a pipes read- and/or write-handle(s) of the
server and client process. The client must be a client-process (see OS/2-docs for details).
To do realy client/server data-communication use DDE (class XDDE) or named pipes (XNamedPipeServer, XNamedPipeClient).
Example:
ULONG hfSave, hfNew = XPIPE_STDERROR;
//save stderror-handle XPipe::DuplicateHandle( XPIPE_STDERROR, hfSave);
//create a pipe and open it XPipe pipe; pipe.Open();
//set the write-handle from the pipe as stderror so the client will write to it XPipe::DuplicateHandle( pipe1.GetWriteHandle(), hfNew);
//start the client-process here XProcess::ExecuteProg(.......);
//close write-handle of the pipe XPipe::CloseHandle( pipe.GetWriteHandle());
//bring the saved handde from stderror back XPipe::DuplicateHandle( hfSave, hfNew);
//close stderror XPipe::CloseHandle(hfSave);
ULONG cbRead; char buffer[XPIPE_DEFAULTSIZE];
do { //read data like a file cbRead = pipe.Read( achBuf, XPIPE_DEFAULTSIZE); } while(cbRead);
//close the pipe pipe.Close();
DuplicateHandle |
Dupplicate a handle.
GetReadHandle |
ULONG readHandle
Returns the read-handle from a pipe
GetWriteHandle |
ULONG writeHandle
Returns the write-handle from a pipe
Close |
Close the pipe.
CloseHandle |
ULONG handle handle to close.
Close a single handle.
Open |
LONG buffersize size of the buffer (default is 4096)
Opens a pipe. Afte it is open you can redirect stdin/stdout/stderr to one of its handles.