1 | // |
---|---|
2 | // MulticastEchoServer.h |
3 | // |
4 | // Definition of the MulticastEchoServer class. |
5 | // |
6 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
7 | // and Contributors. |
8 | // |
9 | // SPDX-License-Identifier: BSL-1.0 |
10 | // |
11 | |
12 | |
13 | #ifndef MulticastEchoServer_INCLUDED |
14 | #define MulticastEchoServer_INCLUDED |
15 | |
16 | |
17 | #include "Poco/Net/Net.h" |
18 | |
19 | |
20 | #ifdef POCO_NET_HAS_INTERFACE |
21 | |
22 | |
23 | #include "Poco/Net/MulticastSocket.h" |
24 | #include "Poco/Net/SocketAddress.h" |
25 | #include "Poco/Net/NetworkInterface.h" |
26 | #include "Poco/Thread.h" |
27 | #include "Poco/Event.h" |
28 | |
29 | |
30 | class MulticastEchoServer: public Poco::Runnable |
31 | /// A simple sequential Multicast echo server. |
32 | { |
33 | public: |
34 | MulticastEchoServer(); |
35 | /// Creates the MulticastEchoServer. |
36 | |
37 | ~MulticastEchoServer(); |
38 | /// Destroys the MulticastEchoServer. |
39 | |
40 | Poco::UInt16 port() const; |
41 | /// Returns the port the echo server is |
42 | /// listening on. |
43 | |
44 | void run(); |
45 | /// Does the work. |
46 | |
47 | const Poco::Net::SocketAddress& group() const; |
48 | /// Returns the group address where the server listens. |
49 | |
50 | const Poco::Net::NetworkInterface& interfc() const; |
51 | /// Returns the network interface for multicasting. |
52 | |
53 | protected: |
54 | static Poco::Net::NetworkInterface findInterface(); |
55 | /// Finds an appropriate network interface for |
56 | /// multicasting. |
57 | |
58 | private: |
59 | Poco::Net::MulticastSocket _socket; |
60 | Poco::Net::SocketAddress _group; |
61 | Poco::Net::NetworkInterface _if; |
62 | Poco::Thread _thread; |
63 | Poco::Event _ready; |
64 | bool _stop; |
65 | }; |
66 | |
67 | |
68 | #endif // POCO_NET_HAS_INTERFACE |
69 | |
70 | |
71 | #endif // MulticastEchoServer_INCLUDED |
72 |