PhoenixSocket  4.0.1
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
PEmptySocket Class Reference

Example of an empty socket. More...

#include <PEmptyBackend.h>

Public Types

typedef DataStreamMsg Message
 Define the type of message used by the PAbstractSocketManager.
 
typedef PEmptyParam Param
 Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.
 

Public Member Functions

void close ()
 Close the PEmptySocket.
 
bool createClientSocket (const PSocketParam &socketParam, const Param &extraParam)
 Initialise a client socket.
 
bool createServerSocket (const PSocketParam &socketParam, const Param &extraParam)
 Initialise a server socket.
 
bool isConnected () const
 Say if the PEmptySocket is connected.
 
 PEmptySocket ()
 Default constructor of hte PEmptySocket.
 
template<typename T>
PRecvStatus::PRecvStatus recvData (T &data, PRecvFlag::PRecvFlag flag)
 Recieved data with the socket.
 
PRecvStatus::PRecvStatus recvMsg (Message &msg, PRecvFlag::PRecvFlag flag)
 Recieved data with the socket.
 
template<typename T>
PSendStatus::PSendStatus sendData (const T &data, PSendFlag::PSendFlag flag)
 Send data with the socket.
 
PSendStatus::PSendStatus sendMsg (const Message &msg, PSendFlag::PSendFlag flag)
 Specialisation to send a Message with the PEmptySocket.
 
void setIsMockRecord (bool isMockRecord)
 Set the mock prefix (where to find/save it)
 
void setMockPrefix (const std::string &mockPrefix)
 Set the mock prefix (where to find/save it)
 
virtual ~PEmptySocket ()
 Default destructor of hte PEmptySocket.
 

Detailed Description

Example of an empty socket.

Definition at line 17 of file PEmptyBackend.h.

Member Typedef Documentation

◆ Message

typedef DataStreamMsg PEmptySocket::Message

Define the type of message used by the PAbstractSocketManager.

Definition at line 20 of file PEmptyBackend.h.

◆ Param

Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.

Definition at line 22 of file PEmptyBackend.h.

Constructor & Destructor Documentation

◆ PEmptySocket()

PEmptySocket::PEmptySocket ( )

Default constructor of hte PEmptySocket.

Definition at line 10 of file PEmptyBackend.cpp.

10 {
11
12}

◆ ~PEmptySocket()

PEmptySocket::~PEmptySocket ( )
virtual

Default destructor of hte PEmptySocket.

Definition at line 15 of file PEmptyBackend.cpp.

15 {
16
17}

Member Function Documentation

◆ close()

void PEmptySocket::close ( )

Close the PEmptySocket.

Definition at line 71 of file PEmptyBackend.cpp.

71 {
72
73}

◆ createClientSocket()

bool PEmptySocket::createClientSocket ( const PSocketParam & socketParam,
const Param & extraParam )

Initialise a client socket.

Parameters
socketParam: parameters to be use to initialise the socket (hostname, port, etc)
extraParam: extra customisable parameters for the creation of the socket (depends on the backend)

Definition at line 23 of file PEmptyBackend.cpp.

23 {
24 return true;
25}

Referenced by PEmptyBackend::createClientSocket().

+ Here is the caller graph for this function:

◆ createServerSocket()

bool PEmptySocket::createServerSocket ( const PSocketParam & socketParam,
const Param & extraParam )

Initialise a server socket.

Parameters
socketParam: parameters to be use to initialise the socket (hostname, port, etc)
extraParam: extra customisable parameters for the creation of the socket (depends on the backend)

Definition at line 31 of file PEmptyBackend.cpp.

31 {
32 return true;
33}

Referenced by PEmptyBackend::createServerSocket().

+ Here is the caller graph for this function:

◆ isConnected()

bool PEmptySocket::isConnected ( ) const

Say if the PEmptySocket is connected.

Returns
true if the PEmptySocket is connected, false otherwise

Definition at line 66 of file PEmptyBackend.cpp.

66 {
67 return true;
68}

◆ recvData()

template<typename T>
PRecvStatus::PRecvStatus PEmptySocket::recvData ( T & data,
PRecvFlag::PRecvFlag flag )

Recieved data with the socket.

Parameters
[out]data: data to be recieved with the socket
flag: recieving flag (BLOCK, NON_BLOCK)
Returns
status of the recv

Definition at line 39 of file PEmptyBackend_impl.h.

39 {
41 Message msg;
42 recvStatus = recvMsg(msg, flag);
43 //If the message is empty we cannot initialise the given data, so, this is an error
44 if(msg.size() != 0lu){
45 DataStreamIter iter = (DataStreamIter)msg.data();
46 if(!data_message_load<T>(iter, data)){
48 }
49 }else{
51 }
52 return recvStatus;
53}
PRecvStatus::PRecvStatus recvMsg(Message &msg, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
PRecvStatus
describe the result of the recv
Definition PSocketFlag.h:52
@ CANNOT_DESERIALIZE_DATA
Definition PSocketFlag.h:60
@ NO_MESSAGE_RECEIVED
Definition PSocketFlag.h:54

References PRecvStatus::CANNOT_DESERIALIZE_DATA, PRecvStatus::NO_MESSAGE_RECEIVED, PRecvStatus::OK, and recvMsg().

+ Here is the call graph for this function:

◆ recvMsg()

Recieved data with the socket.

Parameters
[out]msg: Message to be recieved with the socket
flag: recieving flag (BLOCK, NON_BLOCK)
Returns
status of the recv

Definition at line 59 of file PEmptyBackend.cpp.

59 {
60 return PRecvStatus::OK;
61}

References PRecvStatus::OK.

Referenced by recvData().

+ Here is the caller graph for this function:

◆ sendData()

template<typename T>
PSendStatus::PSendStatus PEmptySocket::sendData ( const T & data,
PSendFlag::PSendFlag flag )

Send data with the socket.

Parameters
data: data to be sent with the socket
flag: sending flag (BLOCK, NON_BLOCK)
Returns
status of the send

Definition at line 19 of file PEmptyBackend_impl.h.

19 {
20 size_t dataSize(data_size<T>(data));
22 Message msg;
23 msg.resize(dataSize);
24 DataStreamIter iter = (DataStreamIter)msg.data();
25 if(data_message_save<T>(iter, data)){ //Save the message
26 sendStatus = sendMsg(msg, flag);
27 }else{
29 }
30 return sendStatus;
31}
PSendStatus::PSendStatus sendMsg(const Message &msg, PSendFlag::PSendFlag flag)
Specialisation to send a Message with the PEmptySocket.
PSendStatus
describe the result of the send
Definition PSocketFlag.h:25
@ CANNOT_SERIALIZE_DATA
Definition PSocketFlag.h:32

References PSendStatus::CANNOT_SERIALIZE_DATA, PSendStatus::OK, and sendMsg().

+ Here is the call graph for this function:

◆ sendMsg()

PSendStatus::PSendStatus PEmptySocket::sendMsg ( const Message & msg,
PSendFlag::PSendFlag flag )

Specialisation to send a Message with the PEmptySocket.

Parameters
msg: Message to be sent
flag: sending flag (BLOCK, NON_BLOCK)
Returns
status of the send

Definition at line 50 of file PEmptyBackend.cpp.

50 {
51 return PSendStatus::OK;
52}

References PSendStatus::OK.

Referenced by sendData().

+ Here is the caller graph for this function:

◆ setIsMockRecord()

void PEmptySocket::setIsMockRecord ( bool isMockRecord)

Set the mock prefix (where to find/save it)

Parameters
isMockRecord: true if the mock has to be recorded

Definition at line 43 of file PEmptyBackend.cpp.

43{}

◆ setMockPrefix()

void PEmptySocket::setMockPrefix ( const std::string & mockPrefix)

Set the mock prefix (where to find/save it)

Parameters
mockPrefix: prefix of the mock to find or write it

Definition at line 38 of file PEmptyBackend.cpp.

38{}

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