summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/SocketListener.cpp26
-rw-r--r--src/server/SocketListener.hpp24
2 files changed, 26 insertions, 24 deletions
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index 82f88ae5..e62b822e 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -39,6 +39,8 @@
namespace Ingen {
namespace Server {
+static constexpr const char* const unix_scheme = "unix://";
+
static std::string
get_link_target(const char* link_path)
{
@@ -59,10 +61,26 @@ get_link_target(const char* link_path)
return std::string();
}
-void
-SocketListener::ingen_listen(Engine* engine,
- Raul::Socket* unix_sock,
- Raul::Socket* net_sock)
+static void ingen_listen(Engine* engine,
+ Raul::Socket* unix_sock,
+ Raul::Socket* net_sock);
+
+
+SocketListener::SocketListener(Engine& engine)
+ : unix_sock(Raul::Socket::Type::UNIX)
+ , net_sock(Raul::Socket::Type::TCP)
+ , thread(new std::thread(ingen_listen, &engine, &unix_sock, &net_sock))
+{}
+
+SocketListener::~SocketListener() {
+ unix_sock.shutdown();
+ net_sock.shutdown();
+ thread->join();
+ unlink(unix_sock.uri().substr(strlen(unix_scheme)).c_str());
+}
+
+static void
+ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock)
{
Ingen::World* world = engine->world();
diff --git a/src/server/SocketListener.hpp b/src/server/SocketListener.hpp
index 71c60d01..e74629ad 100644
--- a/src/server/SocketListener.hpp
+++ b/src/server/SocketListener.hpp
@@ -19,35 +19,19 @@
#include "raul/Socket.hpp"
-#include "Engine.hpp"
-
namespace Ingen {
namespace Server {
+class Engine;
+
/** Listens on main sockets and spawns socket servers for new connections. */
class SocketListener
{
public:
- SocketListener(Engine& engine)
- : unix_sock(Raul::Socket::Type::UNIX)
- , net_sock(Raul::Socket::Type::TCP)
- , thread(new std::thread(ingen_listen, &engine, &unix_sock, &net_sock))
- {}
-
- ~SocketListener() {
- unix_sock.shutdown();
- net_sock.shutdown();
- thread->join();
- unlink(unix_sock.uri().substr(strlen(unix_scheme)).c_str());
- }
+ SocketListener(Engine& engine);
+ ~SocketListener();
private:
- static constexpr const char* unix_scheme = "unix://";
-
- static void ingen_listen(Engine* engine,
- Raul::Socket* unix_sock,
- Raul::Socket* net_sock);
-
Raul::Socket unix_sock;
Raul::Socket net_sock;
std::unique_ptr<std::thread> thread;