Ocean
|
This class is the base class for all package connectionless server. More...
#include <PackagedConnectionlessServer.h>
Data Structures | |
class | MessageData |
This class implements a message. More... | |
class | Triple |
Definition of a triple storing an address, a port and a message id. More... | |
Public Types | |
typedef Callback< void, const Address4 &, const Port &, const void *, const size_t, const MessageId > | ReceiveCallback |
Definition of a data callback function. | |
![]() | |
enum | SocketResult { SR_SUCCEEDED = 0 , SR_FAILED , SR_BUSY , SR_NOT_CONNECTED } |
Definition of individual result values. More... | |
typedef SOCKET | SocketId |
Definition of a socket id. | |
typedef int | SocketId |
Definition of a socket id. | |
typedef std::vector< uint8_t > | Buffer |
Definition of a vector holding 8 bit values. | |
![]() | |
typedef uint32_t | MessageId |
Definition of a message id. | |
Public Member Functions | |
~PackagedConnectionlessServer () override | |
Destructs a connectionless server object. | |
void | setReceiveCallback (const ReceiveCallback &callback) |
Sets the receive data callback function. | |
![]() | |
SocketResult | send (const Address4 &address, const Port &port, const void *data, const size_t size) |
Sends data to a specified recipient. | |
SocketResult | send (const Address4 &address, const Port &port, const std::string &message) |
Sends a message to a specified recipient. | |
size_t | maximalPackageSize () const |
Returns the maximal size of a single package for this client. | |
![]() | |
virtual | ~Socket () |
Destructs a socket object. | |
SocketId | id () const |
Returns the socket id. | |
Address4 | address () const |
Returns the own address of this socket. | |
Port | port () const |
Returns the own port of this socket. | |
virtual bool | setAddress (const Address4 &address) |
Sets the own address of this socket. | |
virtual bool | setPort (const Port &port) |
Sets the own port of this socket. | |
operator bool () const | |
Returns whether this socket is valid. | |
![]() | |
~Server () override | |
Destructs a server object. | |
virtual bool | start () |
Starts the server. | |
virtual bool | stop () |
Stops the server. | |
Protected Types | |
typedef std::map< Triple, MessageData > | MessageMap |
Definition of a map mapping message ids to massage data objects. | |
![]() | |
typedef std::queue< MemoryBlock > | MemoryBlockQueue |
Definition of a queue holding memory blocks. | |
Protected Member Functions | |
PackagedConnectionlessServer () | |
Creates a new connectionless server object. | |
bool | onScheduler () override |
The scheduler event function. | |
![]() | |
PackagedConnectionlessClient () | |
Creates a new packaged connectionless client object. | |
~PackagedConnectionlessClient () override | |
Destructs a packaged connectionless client object. | |
![]() | |
Client () | |
Creates a new client. | |
~Client () override | |
Destructs a client. | |
![]() | |
Socket () | |
Creates a new socket object. | |
Socket (const Socket &object)=delete | |
Disabled copy constructor. | |
bool | setBlockingMode (const bool blocking) |
Sets the blocking mode of this socket. | |
size_t | maximalMessageSize (const size_t defaultSize=65536) |
Returns the maximal message size in bytes. | |
bool | releaseSocket () |
Releases the socket. | |
Socket & | operator= (const Socket &object)=delete |
Disabled copy operator. | |
![]() | |
PackagedSocket () | |
Creates a new packaged socket. | |
![]() | |
Server () | |
Creates a new server object. | |
Protected Attributes | |
ReceiveCallback | receiveCallback_ |
Data callback function called on new message arrivals. | |
double | maximalMessageTime_ = 5.0 |
The time between the first package of a large message and the decision to retire the message if still packages are missing, in seconds. | |
Buffer | packageBuffer_ |
Intermediate buffer storing individual parts of a large message. | |
MessageMap | connectionlessServerMessageMap |
The map holding all partially received message. | |
![]() | |
MessageId | messageCounter_ = 0u |
Client message counter. | |
size_t | maximalPackageSize_ = 0 |
Maximal package size of this connectionless socket (including the header). | |
Buffer | clientPackageBuffer_ |
Intermediate buffer storing individual parts of a large message. | |
![]() | |
Buffer | socketBuffer_ |
The socket buffer of this client. | |
![]() | |
SocketId | socketId_ = invalidSocketId() |
Socket id. | |
Lock | lock_ |
Socket lock. | |
NetworkResource | networkResource_ |
The network resource object. | |
![]() | |
Buffer | buffer_ |
The socket buffer of this server. | |
bool | schedulerIsActive_ = false |
True, if the server scheduler is active. | |
Additional Inherited Members | |
![]() | |
static constexpr SocketId | invalidSocketId () |
Returns an invalid socket id. | |
static bool | setBlockingMode (const SocketId socketId, const bool blocking) |
Sets the blocking mode of a socket. | |
![]() | |
static constexpr MessageId | invalidMessageId () |
Returns an invalid message id. | |
static constexpr size_t | packageManagmentHeaderSize () |
Returns the size of the package management header in bytes. | |
static constexpr size_t | maximalPackagedMessageSize () |
Returns the maximal size of a packaged message. | |
![]() | |
static bool | extractNextPackage (MemoryBlockQueue &sourceQueue, MemoryBlock &targetMemory) |
Extracts a memory block from a queue with memory block. | |
This class is the base class for all package connectionless server.
|
protected |
Definition of a map mapping message ids to massage data objects.
typedef Callback<void, const Address4&, const Port&, const void*, const size_t, const MessageId> Ocean::Network::PackagedConnectionlessServer::ReceiveCallback |
Definition of a data callback function.
Parameter 0 provides the address of the sender.
Parameter 1 provides the port of the sender.
Parameter 2 provides the received buffer, which must be copied, nullptr if the message could not be delivered correctly Parameter 3 provides the size of the received buffer, in bytes; 0 if the message could not be delivered correctly Parameter 4 provides the id of the message to which the received buffer belongs
|
override |
Destructs a connectionless server object.
|
protected |
Creates a new connectionless server object.
|
overrideprotectedvirtual |
|
inline |
Sets the receive data callback function.
callback | the callback function to be called if a new message arrives. |
|
protected |
The map holding all partially received message.
|
protected |
The time between the first package of a large message and the decision to retire the message if still packages are missing, in seconds.
|
protected |
Intermediate buffer storing individual parts of a large message.
|
protected |
Data callback function called on new message arrivals.