41 socket.reset(
new juce::StreamingSocket());
43 if (socket->createListener(portNumber, bindAddress))
45 startThread(m_threadPriority);
55 signalThreadShouldExit();
57 if (socket !=
nullptr)
66 return (socket ==
nullptr) ? -1 : socket->getBoundPort();
69void Ocp1ConnectionServer::run()
71 while ((!threadShouldExit()) && socket !=
nullptr)
73 std::unique_ptr<juce::StreamingSocket> clientSocket(socket->waitForNextConnection());
75 if (clientSocket !=
nullptr)
77 newConnection->initialiseWithSocket(std::move(clientSocket));
Ocp1ConnectionServer(const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal)
Constructs the server.
int getBoundPort() const noexcept
Returns the port number the server is bound to, or -1 if not listening.
~Ocp1ConnectionServer() override
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.
Minimal AES70 / OCP.1 TCP client/server library built on JUCE.