diff options
Diffstat (limited to 'src/UDPServer/UDPServer.h')
-rw-r--r-- | src/UDPServer/UDPServer.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/UDPServer/UDPServer.h b/src/UDPServer/UDPServer.h new file mode 100644 index 0000000..7eef796 --- /dev/null +++ b/src/UDPServer/UDPServer.h @@ -0,0 +1,39 @@ +/* + * http://linux.m2osw.com/c-implementation-udp-clientserver + * + * UDPServer.h + * + * Created on: 29.06.2016 + * Author: Tobias Frust + */ + +#ifndef UDPSERVER_H_ +#define UDPSERVER_H_ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +#include <stdexcept> +#include <string> + +class UDPServer +{ +public: + UDPServer(const std::string& addr, int port); + ~UDPServer(); + + int get_socket() const; + int get_port() const; + std::string get_addr() const; + + int recv(char *msg, size_t max_size); + int timed_recv(char *msg, size_t max_size, int max_wait_ms); + +private: + int f_socket; + int f_port; + std::string f_addr; + struct addrinfo * f_addrinfo; +}; + +#endif /* UDPSERVER_H_ */ |