OpenShot Library | OpenShotAudio  0.2.2
juce::InterprocessConnectionServer Class Referenceabstract

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

#include <juce_InterprocessConnectionServer.h>

+ Inheritance diagram for juce::InterprocessConnectionServer:

Public Member Functions

 InterprocessConnectionServer ()
 Creates an uninitialised server object.
 
 ~InterprocessConnectionServer () override
 Destructor. More...
 
bool beginWaitingForSocket (int portNumber, const String &bindAddress=String())
 Starts an internal thread which listens on the given port number. More...
 
void stop ()
 Terminates the listener thread, if it's active. More...
 
int getBoundPort () const noexcept
 Returns the local port number to which this server is currently bound. More...
 

Protected Member Functions

virtual InterprocessConnectioncreateConnectionObject ()=0
 Creates a suitable connection object for a client process that wants to connect to this one. More...
 

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

Definition at line 43 of file juce_InterprocessConnectionServer.h.

Constructor & Destructor Documentation

◆ ~InterprocessConnectionServer()

juce::InterprocessConnectionServer::~InterprocessConnectionServer ( )
override

Destructor.

Definition at line 30 of file juce_InterprocessConnectionServer.cpp.

References stop().

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

Definition at line 36 of file juce_InterprocessConnectionServer.cpp.

References juce::Thread::startThread(), and stop().

◆ stop()

void juce::InterprocessConnectionServer::stop ( )

Terminates the listener thread, if it's active.

See also
beginWaitingForSocket

Definition at line 52 of file juce_InterprocessConnectionServer.cpp.

References juce::Thread::signalThreadShouldExit(), and juce::Thread::stopThread().

Referenced by beginWaitingForSocket(), and ~InterprocessConnectionServer().

◆ 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.

Definition at line 63 of file juce_InterprocessConnectionServer.cpp.

References createConnectionObject(), and juce::Thread::threadShouldExit().

◆ 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

Referenced by getBoundPort().


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