summaryrefslogtreecommitdiffstats
path: root/src/socket/Socket.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-14 04:23:23 +0000
committerDavid Robillard <d@drobilla.net>2012-08-14 04:23:23 +0000
commit80fee5c311fdbdeda573ec81f59158a5fc87d0a1 (patch)
tree8e7e5a6c9bda32bbe0ae8e8c9f6ab23e44c7c181 /src/socket/Socket.hpp
parent058eaf65642268047a984a5c80d54a1f62a85130 (diff)
downloadingen-80fee5c311fdbdeda573ec81f59158a5fc87d0a1.tar.gz
ingen-80fee5c311fdbdeda573ec81f59158a5fc87d0a1.tar.bz2
ingen-80fee5c311fdbdeda573ec81f59158a5fc87d0a1.zip
Update for latest Raul.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4687 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/socket/Socket.hpp')
-rw-r--r--src/socket/Socket.hpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/socket/Socket.hpp b/src/socket/Socket.hpp
index 13f18be8..49d03d48 100644
--- a/src/socket/Socket.hpp
+++ b/src/socket/Socket.hpp
@@ -18,13 +18,11 @@
#define INGEN_SOCKET_SOCKET_HPP
#include <stdint.h>
-#include <string.h>
#include <sys/socket.h>
-#include <string>
-
-#include "raul/SharedPtr.hpp"
#include "raul/Noncopyable.hpp"
+#include "raul/SharedPtr.hpp"
+#include "raul/URI.hpp"
namespace Ingen {
namespace Socket {
@@ -37,23 +35,19 @@ public:
TCP
};
- static Type type_from_uri(const std::string& uri) {
- if (uri.substr(0, strlen("unix://")) == "unix://") {
- return UNIX;
- } else {
- return TCP;
- }
+ static Type type_from_uri(const Raul::URI uri) {
+ return (uri.scheme() == "unix") ? UNIX : TCP;
}
/** Create a new unbound/unconnected socket of a given type. */
explicit Socket(Type t);
/** Wrap an existing open socket. */
- Socket(Type t,
- const std::string& uri,
- struct sockaddr* addr,
- socklen_t addr_len,
- int fd);
+ Socket(Type t,
+ const Raul::URI& uri,
+ struct sockaddr* addr,
+ socklen_t addr_len,
+ int fd);
~Socket();
@@ -61,13 +55,13 @@ public:
* @param uri Address URI, e.g. unix:///tmp/foo or tcp://somehost:1234
* @return True on success.
*/
- bool bind(const std::string& uri);
+ bool bind(const Raul::URI& uri);
/** Connect a client socket to a server address.
* @param uri Address URI, e.g. unix:///tmp/foo or tcp://somehost:1234
* @return True on success.
*/
- bool connect(const std::string& uri);
+ bool connect(const Raul::URI& uri);
/** Mark server socket as passive to listen for incoming connections.
* @return True on success.
@@ -82,16 +76,16 @@ public:
/** Return the file descriptor for the socket. */
int fd() { return _sock; }
- const std::string& uri() const { return _uri; }
+ const Raul::URI& uri() const { return _uri; }
/** Close the socket. */
void close();
private:
- bool set_addr(const std::string& uri);
+ bool set_addr(const Raul::URI& uri);
Type _type;
- std::string _uri;
+ Raul::URI _uri;
struct sockaddr* _addr;
socklen_t _addr_len;
int _sock;