JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_InterprocessConnectionServer.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
29
34
35//==============================================================================
37{
38 stop();
39
40 socket.reset (new StreamingSocket());
41
42 if (socket->createListener (portNumber, bindAddress))
43 {
45 return true;
46 }
47
48 socket.reset();
49 return false;
50}
51
53{
55
56 if (socket != nullptr)
57 socket->close();
58
59 stopThread (4000);
60 socket.reset();
61}
62
64{
65 return (socket == nullptr) ? -1 : socket->getBoundPort();
66}
67
68void InterprocessConnectionServer::run()
69{
70 while ((! threadShouldExit()) && socket != nullptr)
71 {
72 std::unique_ptr<StreamingSocket> clientSocket (socket->waitForNextConnection());
73
74 if (clientSocket != nullptr)
76 newConnection->initialiseWithSocket (std::move (clientSocket));
77 }
78}
79
80} // namespace juce
int getBoundPort() const noexcept
Returns the local port number to which this server is currently bound.
bool beginWaitingForSocket(int portNumber, const String &bindAddress=String())
Starts an internal thread which listens on the given port number.
virtual InterprocessConnection * createConnectionObject()=0
Creates a suitable connection object for a client process that wants to connect to this one.
InterprocessConnectionServer()
Creates an uninitialised server object.
void stop()
Terminates the listener thread, if it's active.
A wrapper for a streaming (TCP) socket.
Definition juce_Socket.h:82
The JUCE String class!
Definition juce_String.h:53
Encapsulates a thread.
Definition juce_Thread.h:43
bool startThread()
Attempts to start a new thread with default ('Priority::normal') priority.
bool threadShouldExit() const
Checks whether the thread has been told to stop running.
bool stopThread(int timeOutMilliseconds)
Attempts to stop the thread running.
void signalThreadShouldExit()
Sets a flag to tell the thread it should stop.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88