Class Poco::Net::ICMPSocket
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::Net

# class ICMPSocket

Library: Net
Package: ICMP
Header: Poco/Net/ICMPSocket.h

## Description

This class provides an interface to an ICMP client socket.

## Inheritance

Direct Base Classes: Socket

All Base Classes: Socket

## Member Summary

Member Functions: dataSize, operator =, receiveFrom, sendTo, timeout, ttl

Inherited Functions: address, available, close, getBlocking, getKeepAlive, getLinger, getNoDelay, getOOBInline, getOption, getReceiveBufferSize, getReceiveTimeout, getReuseAddress, getReusePort, getSendBufferSize, getSendTimeout, impl, init, operator !=, operator <, operator <=, operator =, operator ==, operator >, operator >=, peerAddress, poll, secure, select, setBlocking, setKeepAlive, setLinger, setNoDelay, setOOBInline, setOption, setReceiveBufferSize, setReceiveTimeout, setReuseAddress, setReusePort, setSendBufferSize, setSendTimeout, sockfd, supportsIPv4, supportsIPv6

## Constructors

### ICMPSocket

ICMPSocket(
const Socket & socket
);

Creates the ICMPSocket with the SocketImpl from another socket. The SocketImpl must be a DatagramSocketImpl, otherwise an InvalidArgumentException will be thrown.

### ICMPSocket

ICMPSocket(
IPAddress::Family family,
int dataSize = 48,
int ttl = 128,
int timeout = 500000
);

Creates an unconnected ICMP socket.

The socket will be created for the given address family.

### ICMPSocket

ICMPSocket(
SocketImpl * pImpl
);

Creates the Socket and attaches the given SocketImpl. The socket takes owership of the SocketImpl.

The SocketImpl must be a ICMPSocketImpl, otherwise an InvalidArgumentException will be thrown.

## Destructor

### ~ICMPSocket

~ICMPSocket();

Destroys the ICMPSocket.

## Member Functions

### dataSize

int dataSize() const;

Returns the data size in bytes.

### operator =

ICMPSocket & operator = (
const Socket & socket
);

Assignment operator.

Releases the socket's SocketImpl and attaches the SocketImpl from the other socket and increments the reference count of the SocketImpl.

### receiveFrom

int receiveFrom(
SocketAddress & address,
int flags = 0
);

Receives data from the socket. Stores the address of the sender in address.

Returns the time elapsed since the originating request was sent.

### sendTo

int sendTo(
const SocketAddress & address,
int flags = 0
);

Sends an ICMP request through the socket to the given address.

Returns the number of bytes sent.

### timeout

int timeout() const;

Returns the socket timeout value.

### ttl

int ttl() const;

Returns the Time-To-Live value.