ICMPSocket.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // ICMPSocket.h
  3. //
  4. // Library: Net
  5. // Package: ICMP
  6. // Module: ICMPSocket
  7. //
  8. // Definition of the ICMPSocket class.
  9. //
  10. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Net_ICMPSocket_INCLUDED
  16. #define Net_ICMPSocket_INCLUDED
  17. #include "Poco/Net/Net.h"
  18. #include "Poco/Net/Socket.h"
  19. namespace Poco {
  20. namespace Net {
  21. class Net_API ICMPSocket: public Socket
  22. /// This class provides an interface to an
  23. /// ICMP client socket.
  24. {
  25. public:
  26. ICMPSocket(SocketAddress::Family family, int dataSize = 48, int ttl = 128, int timeout = 5000000);
  27. /// Creates an unconnected ICMP socket.
  28. ///
  29. /// The socket will be created for the
  30. /// given address family.
  31. ICMPSocket(const Socket& socket);
  32. /// Creates the ICMPSocket with the SocketImpl
  33. /// from another socket. The SocketImpl must be
  34. /// a ICMPSocketImpl, otherwise an InvalidArgumentException
  35. /// will be thrown.
  36. ~ICMPSocket();
  37. /// Destroys the ICMPSocket.
  38. ICMPSocket& operator = (const Socket& socket);
  39. /// Assignment operator.
  40. ///
  41. /// Releases the socket's SocketImpl and
  42. /// attaches the SocketImpl from the other socket and
  43. /// increments the reference count of the SocketImpl.
  44. int sendTo(const SocketAddress& address, int flags = 0);
  45. /// Sends an ICMP request through
  46. /// the socket to the given address.
  47. ///
  48. /// Returns the number of bytes sent.
  49. int receiveFrom(SocketAddress& address, int flags = 0);
  50. /// Receives data from the socket.
  51. /// Stores the address of the sender in address.
  52. ///
  53. /// Returns the time elapsed since the originating
  54. /// request was sent.
  55. int dataSize() const;
  56. /// Returns the data size in bytes.
  57. int ttl() const;
  58. /// Returns the Time-To-Live value.
  59. int timeout() const;
  60. /// Returns the socket timeout value.
  61. protected:
  62. ICMPSocket(SocketImpl* pImpl);
  63. /// Creates the Socket and attaches the given SocketImpl.
  64. /// The socket takes ownership of the SocketImpl.
  65. ///
  66. /// The SocketImpl must be a ICMPSocketImpl, otherwise
  67. /// an InvalidArgumentException will be thrown.
  68. };
  69. } } // namespace Poco::Net
  70. #endif // Net_ICMPSocket_INCLUDED