Scale Stack 0.3 Developer Documentation

scalestack::network::datagram Class Reference

#include <datagram.h>

Inheritance diagram for scalestack::network::datagram:
scalestack::echo::flood::datagram scalestack::echo::server::datagram

Public Member Functions

 datagram (kernel::module &module)
virtual ~datagram ()
virtual void started (void)
virtual void shutdown (void)
void stop (void)
void set_timer (uint64_t milliseconds)
virtual void timer_expired (void)
void run_now (void)
virtual void run (void)
virtual size_t receive (uint8_t *buffer, size_t size, struct sockaddr &peer, socklen_t peer_size)=0
void consume (size_t size)
size_t send (uint8_t *buffer, size_t size, const struct sockaddr &peer, socklen_t peer_size)
size_t send (uint8_t *buffer, size_t size)
virtual void flush_send (void)=0

Protected Attributes

kernel::module_module

Private Member Functions

 datagram (const datagram &)
datagramoperator= (const datagram &)

Private Attributes

datagram_provider_datagram_provider

Friends

class datagram_provider

Detailed Description

This is the base class for classes using datagrams.

Definition at line 48 of file datagram.h.


Constructor & Destructor Documentation

scalestack::network::datagram::datagram ( kernel::module module  )  [inline]

Reimplemented in scalestack::echo::server::datagram.

Definition at line 286 of file datagram.h.

scalestack::network::datagram::~datagram (  )  [inline, virtual]

Reimplemented in scalestack::echo::flood::datagram.

Definition at line 292 of file datagram.h.

scalestack::network::datagram::datagram ( const datagram  )  [private]

Don't allow copying of objects.


Member Function Documentation

void scalestack::network::datagram::started ( void   )  [inline, virtual]

See event::handler::started().

Reimplemented in scalestack::echo::flood::datagram.

Definition at line 296 of file datagram.h.

void scalestack::network::datagram::shutdown ( void   )  [inline, virtual]

See event::handler::shutdown().

Definition at line 300 of file datagram.h.

void scalestack::network::datagram::stop ( void   )  [inline]

See event::handler::stop().

Definition at line 305 of file datagram.h.

void scalestack::network::datagram::set_timer ( uint64_t  milliseconds  )  [inline]

See event::handler::set_timer().

Definition at line 310 of file datagram.h.

void scalestack::network::datagram::timer_expired ( void   )  [inline, virtual]

See event::handler::timer_expired().

Definition at line 315 of file datagram.h.

void scalestack::network::datagram::run_now ( void   )  [inline]

See event::handler::run_now().

Definition at line 319 of file datagram.h.

void scalestack::network::datagram::run ( void   )  [inline, virtual]

See event::handler::run().

Definition at line 324 of file datagram.h.

virtual size_t scalestack::network::datagram::receive ( uint8_t *  buffer,
size_t  size,
struct sockaddr &  peer,
socklen_t  peer_size 
) [pure virtual]

This is called when data has been received and needs to be handled by derived classes.

Parameters:
[in] buffer Data that was read.
[in] size Size of data available in buffer.
[in] peer Socket address the packet was received from.
[in] peer_size Socket address length.
Returns:
Amount of data that was consumed.

Implemented in scalestack::echo::flood::datagram, and scalestack::echo::server::datagram.

void scalestack::network::datagram::consume ( size_t  size  )  [inline]

Notify the socket that the receive buffer has been consumed. This is required after a receive() call was not able to consume all the data. This can be called at a later time to remove the data from the read buffer, such as in flush_send(). After the receive buffer has been flushed, the socket will start watching for new data.

Parameters:
[in] size The amount of data to consume.

Definition at line 328 of file datagram.h.

size_t scalestack::network::datagram::send ( uint8_t *  buffer,
size_t  size,
const struct sockaddr &  peer,
socklen_t  peer_size 
) [inline]

Send data to the socket. This is not buffered. If data could not be written, flush_send() will be called when the socket is ready for writing.

Parameters:
[in] buffer Buffer to write.
[in] size Size of buffer.
[in] peer Socket address to send to.
[in] peer_size Socket address length.
Returns:
Amount of data sent.

Definition at line 333 of file datagram.h.

size_t scalestack::network::datagram::send ( uint8_t *  buffer,
size_t  size 
) [inline]

Same as send(), but use the peer address this datagram was created with. or was last set to with set_peer().

Parameters:
[in] buffer Buffer to write.
[in] size Size of buffer.
Returns:
Amount of data sent.

Definition at line 341 of file datagram.h.

virtual void scalestack::network::datagram::flush_send ( void   )  [pure virtual]

This is called to notify derived classes that they should trying sending data again by calling send(). This is called when the socket is ready for writing after a call to send() could not write data.

Implemented in scalestack::echo::flood::datagram, and scalestack::echo::server::datagram.

datagram& scalestack::network::datagram::operator= ( const datagram  )  [private]

Don't allow assignment of objects.


Friends And Related Function Documentation

friend class datagram_provider [friend]

Definition at line 168 of file datagram.h.


Field Documentation

Definition at line 152 of file datagram.h.

Definition at line 166 of file datagram.h.


The documentation for this class was generated from the following file:
Generated on Thu Feb 17 13:10:22 2011 by  doxygen 1.6.3