CppServer  1.0.0.0
C++ Server Library
Public Member Functions | List of all members
CppServer::Nanomsg::PairServer Class Reference

Nanomsg pair server. More...

#include <pair_server.h>

Inheritance diagram for CppServer::Nanomsg::PairServer:
CppServer::Nanomsg::Server

Public Member Functions

 PairServer (const std::string &address, bool threading=true)
 Initialize server with a given endpoint address. More...
 
 PairServer (const PairServer &)=delete
 
 PairServer (PairServer &&)=default
 
virtual ~PairServer ()=default
 
PairServeroperator= (const PairServer &)=delete
 
PairServeroperator= (PairServer &&)=default
 
- Public Member Functions inherited from CppServer::Nanomsg::Server
 Server (Domain domain, Protocol protocol, const std::string &address, bool threading=true)
 Initialize server with a given domain, protocol and endpoint address. More...
 
 Server (const Server &)=delete
 
 Server (Server &&)=default
 
virtual ~Server ()
 
Serveroperator= (const Server &)=delete
 
Serveroperator= (Server &&)=default
 
Socketsocket () noexcept
 Get the Nanomsg socket. More...
 
bool IsStarted () const noexcept
 Is the server started? More...
 
bool Start ()
 Start the server. More...
 
bool Stop ()
 Stop the server. More...
 
bool Restart ()
 Restart the server. More...
 
size_t Send (const void *buffer, size_t size)
 Send data to the client. More...
 
size_t Send (const std::string &text)
 Send a text string to the client. More...
 
size_t Send (const Message &message)
 Send a message to the client. More...
 
size_t TrySend (const void *buffer, size_t size)
 Try to send data to the client in non-blocking mode. More...
 
size_t TrySend (const std::string &text)
 Try to send a text string to the client in non-blocking mode. More...
 
size_t TrySend (const Message &message)
 Try to send a message to the client in non-blocking mode. More...
 
size_t Receive (Message &message)
 Receive a message from the client. More...
 
size_t TryReceive (Message &message)
 Try to receive a message from the client in non-blocking mode. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CppServer::Nanomsg::Server
virtual void onThreadInitialize ()
 Initialize thread handler. More...
 
virtual void onThreadCleanup ()
 Cleanup thread handler. More...
 
virtual void onStarted ()
 Handle server started notification. More...
 
virtual void onStopped ()
 Handle server stopped notification. More...
 
virtual void onIdle ()
 Handle server idle notification. More...
 
virtual void onReceived (Message &message)
 Handle message received notification. More...
 
virtual void onError (int error, const std::string &message)
 Handle error notification. More...
 

Detailed Description

Nanomsg pair server.

Nanomsg pair server is used to perform a duplex communication with the Nanomsg client.

Pair protocol is the simplest and least scalable scalability protocol. It allows scaling by breaking the application in exactly two pieces. For example, if a monolithic application handles both accounting and agenda of HR department, it can be split into two applications (accounting vs. HR) that are run on two separate servers. These applications can then communicate via PAIR sockets.

The downside of this protocol is that its scaling properties are very limited. Splitting the application into two pieces allows to scale the two servers. To add the third server to the cluster, the application has to be split once more, say by separating HR functionality into hiring module and salary computation module. Whenever possible, try to use one of the more scalable protocols instead.

Thread-safe.

Examples:
nanomsg_pair_server.cpp.

Definition at line 37 of file pair_server.h.

Constructor & Destructor Documentation

◆ PairServer() [1/3]

CppServer::Nanomsg::PairServer::PairServer ( const std::string &  address,
bool  threading = true 
)
inlineexplicit

Initialize server with a given endpoint address.

Parameters
address- Endpoint address
threading- Run the server in a separate thread (default is true)
Examples:
nanomsg_pair_server.cpp.

Definition at line 45 of file pair_server.h.

◆ PairServer() [2/3]

CppServer::Nanomsg::PairServer::PairServer ( const PairServer )
delete

◆ PairServer() [3/3]

CppServer::Nanomsg::PairServer::PairServer ( PairServer &&  )
default

◆ ~PairServer()

virtual CppServer::Nanomsg::PairServer::~PairServer ( )
virtualdefault

Member Function Documentation

◆ operator=() [1/2]

PairServer& CppServer::Nanomsg::PairServer::operator= ( const PairServer )
delete

◆ operator=() [2/2]

PairServer& CppServer::Nanomsg::PairServer::operator= ( PairServer &&  )
default

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