LMMS
Loading...
Searching...
No Matches
juce::InterprocessConnectionServer Class Referenceabstract

#include <juce_InterprocessConnectionServer.h>

Inheritance diagram for juce::InterprocessConnectionServer:
juce::Thread

Public Member Functions

 InterprocessConnectionServer ()
 ~InterprocessConnectionServer () override
bool beginWaitingForSocket (int portNumber, const String &bindAddress=String())
void stop ()
int getBoundPort () const noexcept

Protected Member Functions

virtual InterprocessConnectioncreateConnectionObject ()=0

Private Member Functions

void run () override
Private Member Functions inherited from juce::Thread
 Thread (const String &threadName, size_t threadStackSize=0)
virtual ~Thread ()
void startThread ()
void startThread (int priority)
bool stopThread (int timeOutMilliseconds)
bool isThreadRunning () const
void signalThreadShouldExit ()
bool threadShouldExit () const
bool waitForThreadToExit (int timeOutMilliseconds) const
void addListener (Listener *)
void removeListener (Listener *)
bool setPriority (int priority)
void setAffinityMask (uint32 affinityMask)
bool wait (int timeOutMilliseconds) const
void notify () const
ThreadID getThreadId () const noexcept
const StringgetThreadName () const noexcept

Private Attributes

std::unique_ptr< StreamingSocketsocket

Additional Inherited Members

Private Types inherited from juce::Thread
enum  { realtimeAudioPriority = -1 }
using ThreadID = void*
Static Private Member Functions inherited from juce::Thread
static void launch (std::function< void()> functionToRun)
static bool currentThreadShouldExit ()
static bool setCurrentThreadPriority (int priority)
static void JUCE_CALLTYPE setCurrentThreadAffinityMask (uint32 affinityMask)
static void JUCE_CALLTYPE sleep (int milliseconds)
static void JUCE_CALLTYPE yield ()
static ThreadID JUCE_CALLTYPE getCurrentThreadId ()
static Thread *JUCE_CALLTYPE getCurrentThread ()
static void JUCE_CALLTYPE setCurrentThreadName (const String &newThreadName)

Detailed Description

An object that waits for client sockets to connect to a port on this host, and creates InterprocessConnection objects for each one.

To use this, create a class derived from it which implements the createConnectionObject() method, so that it creates suitable connection objects for each client that tries to connect.

See also
InterprocessConnection

@tags{Events}

Constructor & Destructor Documentation

◆ InterprocessConnectionServer()

juce::InterprocessConnectionServer::InterprocessConnectionServer ( )

Creates an uninitialised server object.

◆ ~InterprocessConnectionServer()

juce::InterprocessConnectionServer::~InterprocessConnectionServer ( )
override

Destructor.

Member Function Documentation

◆ beginWaitingForSocket()

bool juce::InterprocessConnectionServer::beginWaitingForSocket ( int portNumber,
const String & bindAddress = String() )

Starts an internal thread which listens on the given port number.

While this is running, if another process tries to connect with the InterprocessConnection::connectToSocket() method, this object will call createConnectionObject() to create a connection to that client.

Use stop() to stop the thread running.

Parameters
portNumberThe port on which the server will receive connections
bindAddressThe address on which the server will listen for connections. An empty string indicates that it should listen on all addresses assigned to this machine.
See also
createConnectionObject, stop

◆ createConnectionObject()

virtual InterprocessConnection * juce::InterprocessConnectionServer::createConnectionObject ( )
protectedpure virtual

Creates a suitable connection object for a client process that wants to connect to this one.

This will be called by the listener thread when a client process tries to connect, and must return a new InterprocessConnection object that will then run as this end of the connection.

See also
InterprocessConnection

◆ getBoundPort()

int juce::InterprocessConnectionServer::getBoundPort ( ) const
noexcept

Returns the local port number to which this server is currently bound.

This is useful if you need to know to which port the OS has actually bound your socket when calling beginWaitingForSocket with a port number of zero.

Returns -1 if the function fails.

◆ run()

void juce::InterprocessConnectionServer::run ( )
overrideprivatevirtual

Must be implemented to perform the thread's actual code.

Remember that the thread must regularly check the threadShouldExit() method whilst running, and if this returns true it should return from the run() method as soon as possible to avoid being forcibly killed.

See also
threadShouldExit, startThread

Implements juce::Thread.

◆ stop()

void juce::InterprocessConnectionServer::stop ( )

Terminates the listener thread, if it's active.

See also
beginWaitingForSocket

Member Data Documentation

◆ socket

std::unique_ptr<StreamingSocket> juce::InterprocessConnectionServer::socket
private

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