3 #ifndef GRAIL_UDPSERVER_H
4 #define GRAIL_UDPSERVER_H
6 #include "../libs/poco/Net/include/Poco/Net/DatagramSocket.h"
7 #include "../libs/poco/Net/include/Poco/Net/HostEntry.h"
8 #include "../libs/poco/Net/include/Poco/Net/SocketAddress.h"
25 unsigned int serverPort,
26 unsigned long bufferSize = 1024,
27 bool sendFakeNames =
false);
35 void RebuildInterfaces();
37 void StartReceive(
const Poco::Net::IPAddress& ipHost);
39 constexpr
static std::size_t ITERATIONS_BETWEEN_REBUILD{500};
40 constexpr
static Poco::UInt16 UDP_LISTENER_PORT{6661};
41 const static std::string SEARCH_COMMAND;
43 const std::string appName{
""};
44 const unsigned int serverPort{0};
45 const bool sendFakeNames{
false};
46 std::string hostName{
""};
48 std::unique_ptr<std::thread> udpCheckerThread{
nullptr};
50 std::vector<Poco::Net::IPAddress> interfaces{};
51 Poco::Net::HostEntry localHostEntry{};
53 Poco::Net::SocketAddress anyAddress{};
55 std::atomic<bool> isWorking{
false};
57 std::map<std::string, Poco::Net::DatagramSocket> sockets{};
58 char* buffer{
nullptr};
59 unsigned long bufferSize;
60 std::mutex stateChangeMutex{};
65 #endif // GRAIL_UDPSERVER_H