|
NanoOcp
Minimal AES70 / OCP.1 TCP client/server library for d&b Soundscape devices
|
TCP accept-loop server base class for OCP.1 connections. More...
#include <Ocp1ConnectionServer.h>
Inheritance diagram for NanoOcp1::Ocp1ConnectionServer:
Collaboration diagram for NanoOcp1::Ocp1ConnectionServer:Public Member Functions | |
| Ocp1ConnectionServer (const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal) | |
| Constructs the server. | |
| ~Ocp1ConnectionServer () override | |
| bool | beginWaitingForSocket (int portNumber, const juce::String &bindAddress=juce::String()) |
| Binds a TCP socket to the given port and starts the accept-loop thread. | |
| void | stop () |
| Stops the accept-loop thread and closes the listening socket. | |
| int | getBoundPort () const noexcept |
| Returns the port number the server is bound to, or -1 if not listening. | |
Protected Member Functions | |
| virtual Ocp1Connection * | createConnectionObject ()=0 |
| Called by the accept loop each time a new TCP client connects. | |
TCP accept-loop server base class for OCP.1 connections.
Runs a background juce::Thread that blocks on accept() and calls the pure-virtual createConnectionObject() each time a new TCP client connects. The concrete subclass (NanoOcp1Server) implements createConnectionObject() to return a NanoOcp1Client peer wired to the server's callbacks.
Derived from and inspired by juce::InterprocessConnectionServer, stripped of named-pipe and JUCE IPC handshake support.
Definition at line 49 of file Ocp1ConnectionServer.h.
| NanoOcp1::Ocp1ConnectionServer::Ocp1ConnectionServer | ( | const juce::Thread::Priority | threadPriority = juce::Thread::Priority::normal | ) |
Constructs the server.
| threadPriority | OS priority of the accept-loop thread. |
Definition at line 27 of file Ocp1ConnectionServer.cpp.
|
override |
Definition at line 31 of file Ocp1ConnectionServer.cpp.
References stop().
| bool NanoOcp1::Ocp1ConnectionServer::beginWaitingForSocket | ( | int | portNumber, |
| const juce::String & | bindAddress = juce::String() |
||
| ) |
Binds a TCP socket to the given port and starts the accept-loop thread.
| portNumber | Local TCP port to listen on. |
| bindAddress | Local IP address to bind to (empty = all interfaces). |
Definition at line 37 of file Ocp1ConnectionServer.cpp.
References stop().
Referenced by NanoOcp1::NanoOcp1Server::start().
|
protectedpure virtual |
Called by the accept loop each time a new TCP client connects.
Implementations should create and return a new Ocp1Connection-derived object (typically NanoOcp1Client) configured for the accepted socket. The server takes ownership.
Ocp1Connection object for the new client, or nullptr to reject the connection. Implemented in NanoOcp1::NanoOcp1Server.
|
noexcept |
Returns the port number the server is bound to, or -1 if not listening.
Definition at line 64 of file Ocp1ConnectionServer.cpp.
| void NanoOcp1::Ocp1ConnectionServer::stop | ( | ) |
Stops the accept-loop thread and closes the listening socket.
Definition at line 53 of file Ocp1ConnectionServer.cpp.
Referenced by beginWaitingForSocket(), and ~Ocp1ConnectionServer().