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
24using Poco::IOException;
25using Poco::InvalidArgumentException;
26
27
28namespace Poco {
29namespace Net {
30
31
32NTPEventArgs::NTPEventArgs(const SocketAddress& address):
33 _address(address), _packet()
34{
35}
36
37
38NTPEventArgs::~NTPEventArgs()
39{
40}
41
42
43std::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
65std::string NTPEventArgs::hostAddress() const
66{
67 return _address.host().toString();
68}
69
70
71} } // namespace Poco::Net
72