39 #include "blocxx/BLOCXX_config.h"
46 #ifdef BLOCXX_HAVE_UNISTD_H
50 #include <sys/types.h>
52 #include "blocxx/WinUnnamedPipe.hpp"
55 #include <sys/socket.h>
59 namespace BLOCXX_NAMESPACE
72 return this->
write(&value,
sizeof(
int));
79 int len =
static_cast<int>(strData.
length()+1);
80 if ((rc = this->
writeInt(len)) != -1)
90 return this->
read(value,
sizeof(
int));
99 if ((rc = this->
readInt(&len)) != -1)
104 if ((rc = this->
read(p.
get(), len)) != -1)
123 }
while (readbytes > 0);
133 return WinUnnamedPipe::createUnnamedPipe(doOpen);
145 return WinUnnamedPipe::createStdin();
162 return WinUnnamedPipe::createStdout();
179 return WinUnnamedPipe::createStdinStdout();
201 return WinUnnamedPipe::createStderr();
218 return WinUnnamedPipe::createUnnamedPipeFromDescriptor(inputAndOutput);
235 return WinUnnamedPipe::createUnnamedPipeFromDescriptor(input, output);
247 return WinUnnamedPipe::createConnectedPipes(first, second);
250 if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1)
#define BLOCXX_INVALID_HANDLE
static UnnamedPipeRef createStderr()
Create an instance of the concrete class that implements the UnnamedPipe interface connected to stder...
static UnnamedPipeRef createStdout()
Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdou...
int readString(String &strData)
Reads a String from the pipe.
int readInt(int *value)
Reads an int (native binary representation) from the pipe.
static UnnamedPipeRef createStdin()
Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdin...
Abstract interface for an UnnamedPipe.
virtual int write(const void *dataOut, int dataOutLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)=0
Write a specified number of bytes to the device that is exposing the IOIFC interface.
This String class is an abstract data type that represents as NULL terminated string of characters...
#define BLOCXX_DEFINE_EXCEPTION_WITH_ID(NAME)
Define a new exception class named <NAME>Exception that derives from Exception.
handle_type get() const
Return handle of resource, retaining ownership.
virtual int read(void *dataIn, int dataInLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)=0
Read a specified number of bytes from the device that is exposing the IOIFC interface.
String readAll()
Read from the pipe and collect into a string, until the other end of the pipe is closed.
static UnnamedPipeRef createUnnamedPipeFromDescriptor(AutoDescriptor inputAndOutput)
Create an instance of the concrete class that implements the UnnamedPipe interface connected bidirect...
AutoResource< AutoDescriptorPolicy > AutoDescriptor
An analog of std::auto_ptr for descriptors.
PURPOSE: The AutoResource class template is an analog of std::auto_ptr for managing arbitrary resourc...
const char * c_str() const
int writeInt(int value)
Write an int (native binary representation) to the pipe.
The AutoPtrVec class provides a simple class for smart pointers to a dynamically allocated array of o...
X * release()
Release ownership of the underlying array.
IntrusiveReference< UnnamedPipe > UnnamedPipeRef
static UnnamedPipeRef createStdinStdout()
Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdin...
static void createConnectedPipes(UnnamedPipeRef &first, UnnamedPipeRef &second)
Create a connected pair of pipes.
static UnnamedPipeRef createUnnamedPipe(EOpen doOpen=E_OPEN)
Create an instance of the concrete class that implements the UnnamedPipe interface.
int writeString(const String &strData)
Writes a String to the pipe.
#define BLOCXX_THROW_ERRNO_MSG(exType, msg)
Throw an exception using FILE, LINE, errno and strerror(errno)