summaryrefslogtreecommitdiffstats
path: root/src/socket/SocketListener.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-10 02:14:55 +0000
committerDavid Robillard <d@drobilla.net>2012-05-10 02:14:55 +0000
commit281bbcc6a7208c28283bc9bdd521c5d6cc48a60f (patch)
tree6cfc2bf6c3c0d92b3cb5a79a4d019d5952d41989 /src/socket/SocketListener.cpp
parentcd2ac251d7e076e3bf25f2640d1684447efa83d3 (diff)
downloadingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.tar.gz
ingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.tar.bz2
ingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.zip
Bidirectional socket communication (GUI once again works remotely).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4335 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/socket/SocketListener.cpp')
-rw-r--r--src/socket/SocketListener.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp
index 6f41383b..fa58ff44 100644
--- a/src/socket/SocketListener.cpp
+++ b/src/socket/SocketListener.cpp
@@ -29,7 +29,7 @@
#include "../server/Engine.hpp"
#include "../server/EventWriter.hpp"
#include "SocketListener.hpp"
-#include "SocketReader.hpp"
+#include "SocketServer.hpp"
#define LOG(s) s << "[SocketListener] "
@@ -38,13 +38,15 @@ namespace Socket {
SocketListener::SocketListener(Ingen::Shared::World& world)
: _world(world)
+ , _unix_sock(Socket::UNIX)
+ , _net_sock(Socket::TCP)
{
set_name("SocketListener");
// Create UNIX socket
_unix_path = world.conf()->option("socket").get_string();
const std::string unix_uri = "unix://" + _unix_path;
- if (!_unix_sock.open_unix(unix_uri, _unix_path) || !_unix_sock.listen()) {
+ if (!_unix_sock.bind(unix_uri) || !_unix_sock.listen()) {
LOG(Raul::error) << "Failed to create UNIX socket" << std::endl;
_unix_sock.close();
}
@@ -54,7 +56,7 @@ SocketListener::SocketListener(Ingen::Shared::World& world)
std::ostringstream ss;
ss << "tcp:///localhost:";
ss << port;
- if (!_net_sock.open_tcp(ss.str(), port) || !_net_sock.listen()) {
+ if (!_net_sock.bind(ss.str()) || !_net_sock.listen()) {
LOG(Raul::error) << "Failed to create TCP socket" << std::endl;
_net_sock.close();
}
@@ -103,18 +105,16 @@ SocketListener::_run()
}
if (pfds[0].revents & POLLIN) {
- int conn = _unix_sock.accept();
- if (conn != -1) {
- // Make an new interface/thread to handle the connection
- new SocketReader(_world, *engine->interface(), conn);
+ SharedPtr<Socket> conn = _unix_sock.accept();
+ if (conn) {
+ new SocketServer(_world, *engine, conn);
}
}
if (pfds[1].revents & POLLIN) {
- int conn = _net_sock.accept();
- if (conn != -1) {
- // Make an new interface/thread to handle the connection
- new SocketReader(_world, *engine->interface(), conn);
+ SharedPtr<Socket> conn = _net_sock.accept();
+ if (conn) {
+ new SocketServer(_world, *engine, conn);
}
}
}