Files
poco/Net/include/Poco/Net/ICMPClient.h
Aleksandar Fabijanic c4e676d36d Feature net udp (#2347)
* add PMTU discovery #2329

* add socket gather/scatter capabilities #2330 (win, udp)

* enable WSAPoll

* add FastMemoryPool

* add receiveFrom() with native args

* allow copying of StringTokenizer

* add AtomicFlag and SpinlockMutex

* update .gitignore

* UDPServer and client #2343 (windows)

* fix warnings

* fix warnings

* regenerate Net VS solutions

* regenerate CppUnit projects/solutions

* clang fixes

* gcc fixes

* try to fix travis

* more travis fixes

* more travis fixes

* handle UDPClient exception

* fix makefiles and init order warnings

* add UNIX gather/scatter sendto/recvfrom implementations and tests

* run travis tests as sudo

* try to run tests as sudo, 2nd attempt

* fix warning

* use mutex in reactor

* lock-order-inversion in SocketReactor #2346

* add PMTU discovery #2329 (linux)

* ICMPSocket does not check reply address #1921

* remove some ignored tests

* add PMTU discovery #2329 (reconcile logic with #1921)

* fix native receiveFrome()

* reinstate ignoring of proxy errors

* add testMTU to ignore list

* add include atomic

* NTPClient not checking reply address #2348

* some ICMP/MTU fixes

* UDPSocketReader cleanup

* resolve some socket inheritance warnings

* add NTP time sync to ignored tests

* SocketNotifier not thread-safe #2345

* prevent x64 samples build attempt for win32

* build TestApp and Library

* fix ICMP tests

* regen VS projects

* regen VS projects and add missing 2012 files

* remove debug prints
2018-06-02 14:02:33 -05:00

98 lines
2.3 KiB
C++

//
// ICMPClient.h
//
// Library: Net
// Package: ICMP
// Module: ICMPClient
//
// Definition of the ICMPClient class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Net_ICMPClient_INCLUDED
#define Net_ICMPClient_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/ICMPSocket.h"
#include "Poco/Net/ICMPEventArgs.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/BasicEvent.h"
namespace Poco {
namespace Net {
class Net_API ICMPClient
/// This class provides ICMP Ping functionality.
///
/// The events are available when class is instantiated
/// and non-static member functions are called.
///
/// A "lightweight" alternative is direct (without instantiation)
/// use of static member functions.
{
public:
mutable Poco::BasicEvent<ICMPEventArgs> pingBegin;
mutable Poco::BasicEvent<ICMPEventArgs> pingReply;
mutable Poco::BasicEvent<ICMPEventArgs> pingError;
mutable Poco::BasicEvent<ICMPEventArgs> pingEnd;
explicit ICMPClient(SocketAddress::Family family, int dataSize = 48, int ttl = 128, int timeout = 50000);
/// Creates an ICMP client.
~ICMPClient();
/// Destroys the ICMP client.
int ping(SocketAddress& address, int repeat = 1) const;
/// Pings the specified address [repeat] times.
/// Notifications are posted for events.
///
/// Returns the number of valid replies.
int ping(const std::string& address, int repeat = 1) const;
/// Calls ICMPClient::ping(SocketAddress&, int) and
/// returns the result.
///
/// Returns the number of valid replies.
static int ping(SocketAddress& address,
SocketAddress::Family family,
int repeat = 1,
int dataSize = 48,
int ttl = 128,
int timeout = 100000);
/// Pings the specified address [repeat] times.
/// Notifications are not posted for events.
///
/// Returns the number of valid replies.
static int pingIPv4(const std::string& address,
int repeat = 1,
int dataSize = 48,
int ttl = 128,
int timeout = 100000);
/// Calls ICMPClient::ping(SocketAddress&, int) and
/// returns the result.
///
/// Returns the number of valid replies.
private:
mutable SocketAddress::Family _family;
int _dataSize;
int _ttl;
int _timeout;
};
} } // namespace Poco::Net
#endif // Net_ICMPClient_INCLUDED