Kea: isc::asiolink::DummySocket Class Reference

| Kea 3.0.3-git

isc::asiolink::DummySocket Class Reference

The `DummySocket` class is a concrete derived class of `IOSocket` that is not associated with any real socket. More...

Inheritance diagram for isc::asiolink::DummySocket:
[legend]

## Public Member Functions
| DummySocket (const int protocol)
| Constructor from the protocol number.
virtual int | getNative () const
| A dummy derived method of `IOSocket::getNative()`.
virtual int | getProtocol () const
| Return the transport protocol of the socket.
virtual | ~IOSocket ()
| The destructor.

## Additional Inherited Members
Public Types inherited from isc::asiolink::IOSocket
typedef boost::asio::socket_base::reuse_address | ReuseAddress
| Represents SO_REUSEADDR socket option.
static IOSocket & | getDummyUDPSocket ()
| Return a non-usable "dummy" UDP socket for testing.
static IOSocket & | getDummyTCPSocket ()
| Return a non-usable "dummy" TCP socket for testing.
| IOSocket ()
| The default constructor.

## Detailed Description

The `DummySocket` class is a concrete derived class of `IOSocket` that is not associated with any real socket.

This main purpose of this class is tests, where it may be desirable to instantiate an `IOSocket` object without involving system resource allocation such as real network sockets.

Definition at line 20 of file io_socket.cc.

## Constructor & Destructor Documentation

## ◆ DummySocket()

isc::asiolink::DummySocket::DummySocket | ( | const int | protocol | ) |
| inline

Constructor from the protocol number.

The protocol must validly identify a standard network protocol. For example, to specify TCP `protocol` must be `IPPROTO_TCP`.

Parameters

  protocol | The network protocol number for the socket.

Definition at line 31 of file io_socket.cc.

## Member Function Documentation

## ◆ getNative()

virtual int isc::asiolink::DummySocket::getNative | ( |  | ) | const
| inlinevirtual

A dummy derived method of `IOSocket::getNative()`.

This version of method always returns -1 as the object is not associated with a real (native) socket.

Implements isc::asiolink::IOSocket.

Definition at line 37 of file io_socket.cc.

## ◆ getProtocol()

virtual int isc::asiolink::DummySocket::getProtocol | ( |  | ) | const
| inlinevirtual

Return the transport protocol of the socket.

Currently, it returns `IPPROTO_UDP` for UDP sockets, and `IPPROTO_TCP` for TCP sockets.

This method never throws an exception.

Returns
  IPPROTO_UDP for UDP sockets
  IPPROTO_TCP for TCP sockets

Implements isc::asiolink::IOSocket.

Definition at line 39 of file io_socket.cc.

The documentation for this class was generated from the following file:

- io_socket.cc