1 | // |
---|---|
2 | // NTPEventArgs.cpp |
3 | // |
4 | // Library: Net |
5 | // Package: NTP |
6 | // Module: NTPEventArgs |
7 | // |
8 | // Implementation of NTPEventArgs |
9 | // |
10 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #include "Poco/Net/NTPEventArgs.h" |
18 | #include "Poco/Net/SocketAddress.h" |
19 | #include "Poco/Net/DNS.h" |
20 | #include "Poco/Exception.h" |
21 | #include "Poco/Net/NetException.h" |
22 | |
23 | |
24 | using Poco::IOException; |
25 | using Poco::InvalidArgumentException; |
26 | |
27 | |
28 | namespace Poco { |
29 | namespace Net { |
30 | |
31 | |
32 | NTPEventArgs::NTPEventArgs(const SocketAddress& address): |
33 | _address(address), _packet() |
34 | { |
35 | } |
36 | |
37 | |
38 | NTPEventArgs::~NTPEventArgs() |
39 | { |
40 | } |
41 | |
42 | |
43 | std::string NTPEventArgs::hostName() const |
44 | { |
45 | try |
46 | { |
47 | return DNS::resolve(_address.host().toString()).name(); |
48 | } |
49 | catch (HostNotFoundException&) |
50 | { |
51 | } |
52 | catch (NoAddressFoundException&) |
53 | { |
54 | } |
55 | catch (DNSException&) |
56 | { |
57 | } |
58 | catch (IOException&) |
59 | { |
60 | } |
61 | return _address.host().toString(); |
62 | } |
63 | |
64 | |
65 | std::string NTPEventArgs::hostAddress() const |
66 | { |
67 | return _address.host().toString(); |
68 | } |
69 | |
70 | |
71 | } } // namespace Poco::Net |
72 |