summaryrefslogtreecommitdiffstats
path: root/src/UDPClient/UDPClient.h
diff options
context:
space:
mode:
authorTobias Frust <tobiasfrust@gmail.com>2016-07-11 15:15:32 +0200
committerGitHub <noreply@github.com>2016-07-11 15:15:32 +0200
commit8af3d595e2856f81a46a91d67e96f53cb3b25d0f (patch)
treebd2cb6e80b0db90713f9d24de09577125d6f3d85 /src/UDPClient/UDPClient.h
parent13783f932576a285b08cf518a6b0d679aac3c897 (diff)
parent409e2fd20af5620066796e43410a92521376b2c1 (diff)
downloadods-8af3d595e2856f81a46a91d67e96f53cb3b25d0f.tar.gz
ods-8af3d595e2856f81a46a91d67e96f53cb3b25d0f.tar.bz2
ods-8af3d595e2856f81a46a91d67e96f53cb3b25d0f.tar.xz
ods-8af3d595e2856f81a46a91d67e96f53cb3b25d0f.zip
Merge pull request #1 from tobiasfrust/master
Implemented DetectorSimulator with basic functionalities
Diffstat (limited to 'src/UDPClient/UDPClient.h')
-rw-r--r--src/UDPClient/UDPClient.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/UDPClient/UDPClient.h b/src/UDPClient/UDPClient.h
new file mode 100644
index 0000000..f6cf0d6
--- /dev/null
+++ b/src/UDPClient/UDPClient.h
@@ -0,0 +1,44 @@
+/*
+ * http://linux.m2osw.com/c-implementation-udp-clientserver
+ *
+ * UDPSender.h
+ *
+ * Created on: 29.06.2016
+ * Author: Tobias Frust
+ */
+
+#ifndef UDPCLIENT_H_
+#define UDPCLIENT_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <stdexcept>
+#include <cstring>
+
+class udp_client_server_runtime_error : public std::runtime_error
+{
+public:
+ udp_client_server_runtime_error(const char *w) : std::runtime_error(w) {}
+};
+
+
+class UDPClient {
+public:
+ UDPClient(const std::string& addr, int port);
+ ~UDPClient();
+
+ int get_socket() const;
+ int get_port() const;
+ std::string get_addr() const;
+
+ int send(const char *msg, size_t size);
+
+private:
+ int f_socket;
+ int f_port;
+ std::string f_addr;
+ struct addrinfo * f_addrinfo;
+};
+
+#endif /* UDPCLIENT_H_ */