![]() |
Kea 3.0.0
|
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket.
More...
#include <udp_socket.h>
Public Types | |
| enum | { MIN_SIZE = 4096 } |
| Public Types inherited from isc::asiolink::IOSocket | |
| typedef boost::asio::socket_base::reuse_address | ReuseAddress |
| Represents SO_REUSEADDR socket option. | |
Public Member Functions | |
| UDPSocket (boost::asio::ip::udp::socket &socket) | |
| Constructor from an ASIO UDP socket. | |
| UDPSocket (const IOServicePtr &service) | |
| Constructor. | |
| virtual | ~UDPSocket () |
| Destructor. | |
| virtual void | asyncReceive (void *data, size_t length, size_t offset, IOEndpoint *endpoint, C &callback) |
| Receive Asynchronously. | |
| virtual void | asyncSend (const void *data, size_t length, const IOEndpoint *endpoint, C &callback) |
| Send Asynchronously. | |
| virtual void | cancel () |
| Cancel I/O On Socket. | |
| virtual void | close () |
| Close socket. | |
| virtual int | getNative () const |
| Return file descriptor of underlying socket. | |
| virtual int | getProtocol () const |
| Return protocol of socket. | |
| virtual bool | isOpenSynchronous () const |
| Is "open()" synchronous? | |
| virtual void | open (const IOEndpoint *endpoint, C &callback) |
| Open Socket. | |
| virtual bool | processReceivedData (const void *staging, size_t length, size_t &cumulative, size_t &offset, size_t &expected, isc::util::OutputBufferPtr &buff) |
| Process received data. | |
| virtual | ~IOAsioSocket ()=default |
| The destructor. | |
| virtual | ~IOSocket () |
| The destructor. | |
Additional Inherited Members | |
| static IOSocket & | getDummyUDPSocket () |
| Return a non-usable "dummy" UDP socket for testing. | |
| static IOSocket & | getDummyTCPSocket () |
| Return a non-usable "dummy" TCP socket for testing. | |
| IOAsioSocket () | |
| The default constructor. | |
| IOSocket () | |
| The default constructor. | |
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket.
| C | Callback type |
Definition at line 35 of file udp_socket.h.
| anonymous enum |
| Enumerator | |
|---|---|
| MIN_SIZE | |
Definition at line 42 of file udp_socket.h.
| isc::asiolink::UDPSocket< C >::UDPSocket | ( | boost::asio::ip::udp::socket & | socket | ) |
Constructor from an ASIO UDP socket.
| socket | The ASIO representation of the UDP socket. It is assumed that the caller will open and close the socket, so these operations are a no-op for that socket. |
Definition at line 166 of file udp_socket.h.
| isc::asiolink::UDPSocket< C >::UDPSocket | ( | const IOServicePtr & | service | ) |
Constructor.
Used when the UDPSocket is being asked to manage its own internal socket. In this case, the open() and close() methods are used.
| service | I/O Service object used to manage the socket. |
Definition at line 173 of file udp_socket.h.
|
virtual |
Destructor.
Definition at line 181 of file udp_socket.h.
References close().
|
virtual |
Receive Asynchronously.
Calls the underlying socket's async_receive_from() method to read a packet of data from a remote endpoint. Arrival of the data is signalled via a call to the callback function.
| data | Buffer to receive incoming message |
| length | Length of the data buffer |
| offset | Offset into buffer where data is to be put |
| endpoint | Source of the communication |
| callback | Callback object |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 250 of file udp_socket.h.
References isc::asiolink::UDPEndpoint::getASIOEndpoint(), isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.
|
virtual |
Send Asynchronously.
Calls the underlying socket's async_send_to() method to send a packet of data asynchronously to the remote endpoint. The callback will be called on completion.
| data | Data to send |
| length | Length of data to send |
| endpoint | Target of the send |
| callback | Callback object. |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 224 of file udp_socket.h.
References isc::asiolink::UDPEndpoint::getASIOEndpoint(), isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.
|
virtual |
Cancel I/O On Socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 297 of file udp_socket.h.
|
virtual |
Close socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 307 of file udp_socket.h.
Referenced by ~UDPSocket().
|
inlinevirtual |
Return file descriptor of underlying socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 65 of file udp_socket.h.
|
inlinevirtual |
Return protocol of socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 70 of file udp_socket.h.
|
inlinevirtual |
Is "open()" synchronous?
Indicates that the opening of a UDP socket is synchronous.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 77 of file udp_socket.h.
|
virtual |
Open Socket.
Opens the UDP socket. This is a synchronous operation.
| endpoint | Endpoint to which the socket will send data. This is used to determine the address family that should be used for the underlying socket. |
| callback | Unused as the operation is synchronous. |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 188 of file udp_socket.h.
References isc::asiolink::IOEndpoint::getFamily(), and MIN_SIZE.
|
virtual |
Process received data.
See the description of IOAsioSocket::receiveComplete for a complete description of this method.
| staging | Pointer to the start of the staging buffer. |
| length | Amount of data in the staging buffer. |
| cumulative | Amount of data received before the staging buffer is processed. |
| offset | Unused. |
| expected | unused. |
| buff | Output buffer. Data in the staging buffer is be copied to this output buffer in the call. |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 278 of file udp_socket.h.