Ocean
Ocean::Network::PackagedConnectionlessServer Class Reference

This class is the base class for all package connectionless server. More...

Inheritance diagram for Ocean::Network::PackagedConnectionlessServer:

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 MessageIdReceiveCallback
 Definition of a data callback function. More...
 
- Public Types inherited from Ocean::Network::Socket
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. More...
 
typedef int SocketId
 Definition of a socket id. More...
 
typedef std::vector< uint8_t > Buffer
 Definition of a vector holding 8 bit values. More...
 
- Public Types inherited from Ocean::Network::PackagedSocket
typedef uint32_t MessageId
 Definition of a message id. More...
 

Public Member Functions

 ~PackagedConnectionlessServer () override
 Destructs a connectionless server object. More...
 
void setReceiveCallback (const ReceiveCallback &callback)
 Sets the receive data callback function. More...
 
- Public Member Functions inherited from Ocean::Network::PackagedConnectionlessClient
SocketResult send (const Address4 &address, const Port &port, const void *data, const size_t size)
 Sends data to a specified recipient. More...
 
SocketResult send (const Address4 &address, const Port &port, const std::string &message)
 Sends a message to a specified recipient. More...
 
size_t maximalPackageSize () const
 Returns the maximal size of a single package for this client. More...
 
- Public Member Functions inherited from Ocean::Network::Socket
virtual ~Socket ()
 Destructs a socket object. More...
 
SocketId id () const
 Returns the socket id. More...
 
Address4 address () const
 Returns the own address of this socket. More...
 
Port port () const
 Returns the own port of this socket. More...
 
virtual bool setAddress (const Address4 &address)
 Sets the own address of this socket. More...
 
virtual bool setPort (const Port &port)
 Sets the own port of this socket. More...
 
 operator bool () const
 Returns whether this socket is valid. More...
 
- Public Member Functions inherited from Ocean::Network::Server
 ~Server () override
 Destructs a server object. More...
 
virtual bool start ()
 Starts the server. More...
 
virtual bool stop ()
 Stops the server. More...
 

Protected Types

typedef std::map< Triple, MessageDataMessageMap
 Definition of a map mapping message ids to massage data objects. More...
 
- Protected Types inherited from Ocean::Network::PackagedSocket
typedef std::queue< MemoryBlockMemoryBlockQueue
 Definition of a queue holding memory blocks. More...
 

Protected Member Functions

 PackagedConnectionlessServer ()
 Creates a new connectionless server object. More...
 
bool onScheduler () override
 The scheduler event function. More...
 
- Protected Member Functions inherited from Ocean::Network::PackagedConnectionlessClient
 PackagedConnectionlessClient ()
 Creates a new packaged connectionless client object. More...
 
 ~PackagedConnectionlessClient () override
 Destructs a packaged connectionless client object. More...
 
- Protected Member Functions inherited from Ocean::Network::Client
 Client ()
 Creates a new client. More...
 
 ~Client () override
 Destructs a client. More...
 
- Protected Member Functions inherited from Ocean::Network::Socket
 Socket ()
 Creates a new socket object. More...
 
 Socket (const Socket &object)=delete
 Disabled copy constructor. More...
 
bool setBlockingMode (const bool blocking)
 Sets the blocking mode of this socket. More...
 
size_t maximalMessageSize (const size_t defaultSize=65536)
 Returns the maximal message size in bytes. More...
 
bool releaseSocket ()
 Releases the socket. More...
 
Socketoperator= (const Socket &object)=delete
 Disabled copy operator. More...
 
- Protected Member Functions inherited from Ocean::Network::PackagedSocket
 PackagedSocket ()
 Creates a new packaged socket. More...
 
- Protected Member Functions inherited from Ocean::Network::Server
 Server ()
 Creates a new server object. More...
 

Protected Attributes

ReceiveCallback receiveCallback_
 Data callback function called on new message arrivals. More...
 
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. More...
 
Buffer packageBuffer_
 Intermediate buffer storing individual parts of a large message. More...
 
MessageMap connectionlessServerMessageMap
 The map holding all partially received message. More...
 
- Protected Attributes inherited from Ocean::Network::PackagedConnectionlessClient
MessageId messageCounter_ = 0u
 Client message counter. More...
 
size_t maximalPackageSize_ = 0
 Maximal package size of this connectionless socket (including the header). More...
 
Buffer clientPackageBuffer_
 Intermediate buffer storing individual parts of a large message. More...
 
- Protected Attributes inherited from Ocean::Network::Client
Buffer socketBuffer_
 The socket buffer of this client. More...
 
- Protected Attributes inherited from Ocean::Network::Socket
SocketId socketId_ = invalidSocketId()
 Socket id. More...
 
Lock lock_
 Socket lock. More...
 
NetworkResource networkResource_
 The network resource object. More...
 
- Protected Attributes inherited from Ocean::Network::Server
Buffer buffer_
 The socket buffer of this server. More...
 
bool schedulerIsActive_ = false
 True, if the server scheduler is active. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::Network::Socket
static constexpr SocketId invalidSocketId ()
 Returns an invalid socket id. More...
 
static bool setBlockingMode (const SocketId socketId, const bool blocking)
 Sets the blocking mode of a socket. More...
 
- Static Public Member Functions inherited from Ocean::Network::PackagedSocket
static constexpr MessageId invalidMessageId ()
 Returns an invalid message id. More...
 
static constexpr size_t packageManagmentHeaderSize ()
 Returns the size of the package management header in bytes. More...
 
static constexpr size_t maximalPackagedMessageSize ()
 Returns the maximal size of a packaged message. More...
 
- Static Protected Member Functions inherited from Ocean::Network::PackagedSocket
static bool extractNextPackage (MemoryBlockQueue &sourceQueue, MemoryBlock &targetMemory)
 Extracts a memory block from a queue with memory block. More...
 

Detailed Description

This class is the base class for all package connectionless server.

Member Typedef Documentation

◆ MessageMap

Definition of a map mapping message ids to massage data objects.

◆ ReceiveCallback

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

Constructor & Destructor Documentation

◆ ~PackagedConnectionlessServer()

Ocean::Network::PackagedConnectionlessServer::~PackagedConnectionlessServer ( )
override

Destructs a connectionless server object.

◆ PackagedConnectionlessServer()

Ocean::Network::PackagedConnectionlessServer::PackagedConnectionlessServer ( )
protected

Creates a new connectionless server object.

Member Function Documentation

◆ onScheduler()

bool Ocean::Network::PackagedConnectionlessServer::onScheduler ( )
overrideprotectedvirtual

The scheduler event function.

Socket::onScheduler().

Reimplemented from Ocean::Network::Socket.

◆ setReceiveCallback()

void Ocean::Network::PackagedConnectionlessServer::setReceiveCallback ( const ReceiveCallback callback)
inline

Sets the receive data callback function.

Parameters
callbackthe callback function to be called if a new message arrives.

Field Documentation

◆ connectionlessServerMessageMap

MessageMap Ocean::Network::PackagedConnectionlessServer::connectionlessServerMessageMap
protected

The map holding all partially received message.

◆ maximalMessageTime_

double Ocean::Network::PackagedConnectionlessServer::maximalMessageTime_ = 5.0
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.

◆ packageBuffer_

Buffer Ocean::Network::PackagedConnectionlessServer::packageBuffer_
protected

Intermediate buffer storing individual parts of a large message.

◆ receiveCallback_

ReceiveCallback Ocean::Network::PackagedConnectionlessServer::receiveCallback_
protected

Data callback function called on new message arrivals.


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