From 7420a170928da75cb860e3fc8804416babdeec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 12 Aug 2023 17:53:08 +0200 Subject: New class for network protocol implementation --- src/network/protocol.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/network/protocol.h (limited to 'src/network/protocol.h') 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 + +#include +#include + +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 & buffer, sockaddr_in6 & addr); + void sendto(const vector & buffer, sockaddr_in addr); + void sendto(const vector & buffer, sockaddr_in6 addr); + + void shutdown(); + +private: + int sock; +}; + +} -- cgit v1.2.3