Kea  1.9.9-git
isc::asiolink::UDPSocket< C > Class Template Reference

The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket. More...

#include <udp_socket.h>

+ Inheritance diagram for isc::asiolink::UDPSocket< C >:

Public Types

enum  { MIN_SIZE = 4096 }
 

Public Member Functions

 UDPSocket (boost::asio::ip::udp::socket &socket)
 Constructor from an ASIO UDP socket. More...
 
 UDPSocket (IOService &service)
 Constructor. More...
 
virtual ~UDPSocket ()
 Destructor. More...
 
virtual void asyncReceive (void *data, size_t length, size_t offset, IOEndpoint *endpoint, C &callback)
 Receive Asynchronously. More...
 
virtual void asyncSend (const void *data, size_t length, const IOEndpoint *endpoint, C &callback)
 Send Asynchronously. More...
 
virtual void cancel ()
 Cancel I/O On Socket. More...
 
virtual void close ()
 Close socket. More...
 
virtual int getNative () const
 Return file descriptor of underlying socket. More...
 
virtual int getProtocol () const
 Return protocol of socket. More...
 
virtual bool isOpenSynchronous () const
 Is "open()" synchronous? More...
 
virtual void open (const IOEndpoint *endpoint, C &callback)
 Open Socket. More...
 
virtual bool processReceivedData (const void *staging, size_t length, size_t &cumulative, size_t &offset, size_t &expected, isc::util::OutputBufferPtr &outbuff)
 Process received data. More...
 

Additional Inherited Members

Detailed Description

template<typename C>
class isc::asiolink::UDPSocket< C >

The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket.

Parameters
CCallback type

Definition at line 35 of file udp_socket.h.

Member Enumeration Documentation

template<typename C >
anonymous enum
Enumerator
MIN_SIZE 

Definition at line 42 of file udp_socket.h.

Constructor & Destructor Documentation

template<typename C >
isc::asiolink::UDPSocket< C >::UDPSocket ( boost::asio::ip::udp::socket &  socket)

Constructor from an ASIO UDP socket.

Parameters
socketThe 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 167 of file udp_socket.h.

template<typename C >
isc::asiolink::UDPSocket< C >::UDPSocket ( IOService 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.

Parameters
serviceI/O Service object used to manage the socket.

Definition at line 175 of file udp_socket.h.

template<typename C >
isc::asiolink::UDPSocket< C >::~UDPSocket ( )
virtual

Destructor.

Definition at line 184 of file udp_socket.h.

Member Function Documentation

template<typename C >
void isc::asiolink::UDPSocket< C >::asyncReceive ( void *  data,
size_t  length,
size_t  offset,
IOEndpoint endpoint,
C &  callback 
)
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.

Parameters
dataBuffer to receive incoming message
lengthLength of the data buffer
offsetOffset into buffer where data is to be put
endpointSource of the communication
callbackCallback object

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 255 of file udp_socket.h.

References isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.

+ Here is the call graph for this function:

template<typename C >
void isc::asiolink::UDPSocket< C >::asyncSend ( const void *  data,
size_t  length,
const IOEndpoint endpoint,
C &  callback 
)
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.

Parameters
dataData to send
lengthLength of data to send
endpointTarget of the send
callbackCallback object.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 228 of file udp_socket.h.

References isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.

+ Here is the call graph for this function:

template<typename C >
void isc::asiolink::UDPSocket< C >::cancel ( )
virtual

Cancel I/O On Socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 304 of file udp_socket.h.

template<typename C >
void isc::asiolink::UDPSocket< C >::close ( )
virtual

Close socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 314 of file udp_socket.h.

template<typename C >
virtual int isc::asiolink::UDPSocket< C >::getNative ( ) const
inlinevirtual

Return file descriptor of underlying socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 65 of file udp_socket.h.

template<typename C >
virtual int isc::asiolink::UDPSocket< C >::getProtocol ( ) const
inlinevirtual

Return protocol of socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 74 of file udp_socket.h.

template<typename C >
virtual bool isc::asiolink::UDPSocket< C >::isOpenSynchronous ( ) const
inlinevirtual

Is "open()" synchronous?

Indicates that the opening of a UDP socket is synchronous.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 81 of file udp_socket.h.

template<typename C >
void isc::asiolink::UDPSocket< C >::open ( const IOEndpoint endpoint,
C &  callback 
)
virtual

Open Socket.

Opens the UDP socket. This is a synchronous operation.

Parameters
endpointEndpoint to which the socket will send data. This is used to determine the address family that should be used for the underlying socket.
callbackUnused as the operation is synchronous.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 191 of file udp_socket.h.

References isc::asiolink::IOEndpoint::getFamily().

+ Here is the call graph for this function:

template<typename C >
bool isc::asiolink::UDPSocket< C >::processReceivedData ( const void *  staging,
size_t  length,
size_t &  cumulative,
size_t &  offset,
size_t &  expected,
isc::util::OutputBufferPtr outbuff 
)
virtual

Process received data.

See the description of IOAsioSocket::receiveComplete for a complete description of this method.

Parameters
stagingPointer to the start of the staging buffer.
lengthAmount of data in the staging buffer.
cumulativeAmount of data received before the staging buffer is processed.
offsetUnused.
expectedunused.
outbuffOutput buffer. Data in the staging buffer is be copied to this output buffer in the call.
Returns
Always true

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 284 of file udp_socket.h.


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