NanoOcp
Minimal AES70 / OCP.1 TCP client/server library for d&b Soundscape devices
Loading...
Searching...
No Matches
Ocp1ConnectionServer.h
Go to the documentation of this file.
1/* Copyright (c) 2023, Christian Ahrens
2 *
3 * This file is part of NanoOcp <https://github.com/ChristianAhrens/NanoOcp>
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#pragma once
20
21#ifdef JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED
22 #include <juce_core/juce_core.h>
23#else
24 #include <JuceHeader.h>
25#endif
26
27
28namespace NanoOcp1
29{
30
31class Ocp1Connection;
32
33
49class Ocp1ConnectionServer : private juce::Thread
50{
51public:
52 //==============================================================================
57 Ocp1ConnectionServer(const juce::Thread::Priority threadPriority = juce::Thread::Priority::normal);
58 ~Ocp1ConnectionServer() override;
59
66 bool beginWaitingForSocket(int portNumber, const juce::String& bindAddress = juce::String());
67
69 void stop();
70
72 int getBoundPort() const noexcept;
73
74protected:
75 //==============================================================================
87
88private:
89 //==============================================================================
90 std::unique_ptr<juce::StreamingSocket> socket;
91
92 void run() override;
93
94 juce::Thread::Priority m_threadPriority;
95
96 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Ocp1ConnectionServer)
97};
98
99}
TCP accept-loop server base class for OCP.1 connections.
int getBoundPort() const noexcept
Returns the port number the server is bound to, or -1 if not listening.
void stop()
Stops the accept-loop thread and closes the listening socket.
bool beginWaitingForSocket(int portNumber, const juce::String &bindAddress=juce::String())
Binds a TCP socket to the given port and starts the accept-loop thread.
virtual Ocp1Connection * createConnectionObject()=0
Called by the accept loop each time a new TCP client connects.
Low-level TCP socket manager for a single OCP.1 connection.
Minimal AES70 / OCP.1 TCP client/server library built on JUCE.
Definition NanoOcp1.cpp:23