summaryrefslogtreecommitdiffstats
path: root/src/socket/Socket.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-02-23 21:23:16 +0000
committerDavid Robillard <d@drobilla.net>2013-02-23 21:23:16 +0000
commit400bbe503f44d306f5488eb850cde0723f8844f5 (patch)
tree0346e64e6e4a03bc25c3b455408cb086f28c9b97 /src/socket/Socket.hpp
parentdfad81a3c8aee40a515f0ecefb0180a86368b54a (diff)
downloadingen-400bbe503f44d306f5488eb850cde0723f8844f5.tar.gz
ingen-400bbe503f44d306f5488eb850cde0723f8844f5.tar.bz2
ingen-400bbe503f44d306f5488eb850cde0723f8844f5.zip
Move Socket class to Raul.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5079 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/socket/Socket.hpp')
-rw-r--r--src/socket/Socket.hpp104
1 files changed, 0 insertions, 104 deletions
diff --git a/src/socket/Socket.hpp b/src/socket/Socket.hpp
deleted file mode 100644
index ebe9f68f..00000000
--- a/src/socket/Socket.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_SOCKET_SOCKET_HPP
-#define INGEN_SOCKET_SOCKET_HPP
-
-#include <stdint.h>
-#include <sys/socket.h>
-
-#include "raul/Noncopyable.hpp"
-#include "raul/URI.hpp"
-
-#include "ingen/types.hpp"
-
-namespace Ingen {
-namespace Socket {
-
-/** A safe and simple interface for UNIX or TCP sockets. */
-class Socket : public Raul::Noncopyable {
-public:
- enum class Type {
- UNIX,
- TCP
- };
-
- static Type type_from_uri(const Raul::URI uri) {
- return (uri.scheme() == "unix") ? Type::UNIX : Type::TCP;
- }
-
- /** Create a new unbound/unconnected socket of a given type. */
- explicit Socket(Type t);
-
- /** Wrap an existing open socket. */
- Socket(Type t,
- const Raul::URI& uri,
- struct sockaddr* addr,
- socklen_t addr_len,
- int fd);
-
- ~Socket();
-
- /** Bind a server socket to an address.
- * @param uri Address URI, e.g. unix:///tmp/foo or tcp://somehost:1234
- * @return True on success.
- */
- 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 Raul::URI& uri);
-
- /** Mark server socket as passive to listen for incoming connections.
- * @return True on success.
- */
- bool listen();
-
- /** Accept a connection.
- * @return An new open socket for the connection.
- */
- SPtr<Socket> accept();
-
- /** Return the file descriptor for the socket. */
- int fd() { return _sock; }
-
- const Raul::URI& uri() const { return _uri; }
-
- /** Close the socket. */
- void close();
-
- /** Shut down the socket.
- * This terminates any connections associated with the sockets, and will
- * (unlike close()) cause a poll on the socket to return.
- */
- void shutdown();
-
-private:
- bool set_addr(const Raul::URI& uri);
-
- Type _type;
- Raul::URI _uri;
- struct sockaddr* _addr;
- socklen_t _addr_len;
- int _sock;
-};
-
-} // namespace Socket
-} // namespace Ingen
-
-#endif // INGEN_SOCKET_SOCKET_HPP