JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::NamedPipe Class Referencefinal

A cross-process pipe that can have data written to and read from it. More...

#include <juce_NamedPipe.h>

Collaboration diagram for juce::NamedPipe:

Public Member Functions

 NamedPipe ()
 Creates a NamedPipe. More...
 
 ~NamedPipe ()
 Destructor. More...
 
void close ()
 Closes the pipe, if it's open. More...
 
bool createNewPipe (const String &pipeName, bool mustNotExist=false)
 Tries to create a new pipe. More...
 
String getName () const
 Returns the last name that was used to try to open this pipe. More...
 
bool isOpen () const
 True if the pipe is currently open. More...
 
bool openExisting (const String &pipeName)
 Tries to open a pipe that already exists. More...
 
int read (void *destBuffer, int maxBytesToRead, int timeOutMilliseconds)
 Reads data from the pipe. More...
 
int write (const void *sourceBuffer, int numBytesToWrite, int timeOutMilliseconds)
 Writes some data to the pipe. More...
 

Private Member Functions

bool openInternal (const String &pipeName, bool createPipe, bool mustNotExist)
 

Private Attributes

String currentPipeName
 
ReadWriteLock lock
 
std::unique_ptr< Pimpl > pimpl
 

Detailed Description

A cross-process pipe that can have data written to and read from it.

Two processes can use NamedPipe objects to exchange blocks of data.

See also
InterprocessConnection

@tags{Core}

Constructor & Destructor Documentation

◆ NamedPipe()

juce::NamedPipe::NamedPipe ( )

Creates a NamedPipe.

◆ ~NamedPipe()

juce::NamedPipe::~NamedPipe ( )

Destructor.

Member Function Documentation

◆ close()

void juce::NamedPipe::close ( )

Closes the pipe, if it's open.

◆ createNewPipe()

bool juce::NamedPipe::createNewPipe ( const String pipeName,
bool  mustNotExist = false 
)

Tries to create a new pipe.

Returns true if it succeeds. If mustNotExist is true then it will fail if a pipe is already open with the same name.

◆ getName()

String juce::NamedPipe::getName ( ) const

Returns the last name that was used to try to open this pipe.

◆ isOpen()

bool juce::NamedPipe::isOpen ( ) const

True if the pipe is currently open.

◆ openExisting()

bool juce::NamedPipe::openExisting ( const String pipeName)

Tries to open a pipe that already exists.

Returns true if it succeeds.

◆ openInternal()

bool juce::NamedPipe::openInternal ( const String pipeName,
bool  createPipe,
bool  mustNotExist 
)
private

◆ read()

int juce::NamedPipe::read ( void *  destBuffer,
int  maxBytesToRead,
int  timeOutMilliseconds 
)

Reads data from the pipe.

This will block until another thread has written enough data into the pipe to fill the number of bytes specified, or until another thread calls the cancelPendingReads() method.

If the operation fails, it returns -1, otherwise, it will return the number of bytes read.

If timeOutMilliseconds is less than zero, it will wait indefinitely, otherwise this is a maximum timeout for reading from the pipe.

◆ write()

int juce::NamedPipe::write ( const void *  sourceBuffer,
int  numBytesToWrite,
int  timeOutMilliseconds 
)

Writes some data to the pipe.

Returns
the number of bytes written, or -1 on failure.

Member Data Documentation

◆ currentPipeName

String juce::NamedPipe::currentPipeName
private

◆ lock

ReadWriteLock juce::NamedPipe::lock
private

◆ pimpl

std::unique_ptr<Pimpl> juce::NamedPipe::pimpl
private

The documentation for this class was generated from the following file: