summaryrefslogtreecommitdiff
path: root/src/network/protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/protocol.h')
-rw-r--r--src/network/protocol.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/network/protocol.h b/src/network/protocol.h
new file mode 100644
index 0000000..6a22f3b
--- /dev/null
+++ b/src/network/protocol.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <netinet/in.h>
+
+#include <cstdint>
+#include <vector>
+
+namespace erebos {
+
+using std::vector;
+
+class NetworkProtocol
+{
+public:
+ NetworkProtocol();
+ explicit NetworkProtocol(int sock);
+ NetworkProtocol(const NetworkProtocol &) = delete;
+ NetworkProtocol(NetworkProtocol &&);
+ NetworkProtocol & operator=(const NetworkProtocol &) = delete;
+ NetworkProtocol & operator=(NetworkProtocol &&);
+ ~NetworkProtocol();
+
+ bool recvfrom(vector<uint8_t> & buffer, sockaddr_in6 & addr);
+ void sendto(const vector<uint8_t> & buffer, sockaddr_in addr);
+ void sendto(const vector<uint8_t> & buffer, sockaddr_in6 addr);
+
+ void shutdown();
+
+private:
+ int sock;
+};
+
+}