PhoenixSocket  5.0.0
Library which integrates socket use in Phoenix
Loading...
Searching...
No Matches
PSocketFlag.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __PSOCKET_FLAG_H__
8#define __PSOCKET_FLAG_H__
9
10#include <string>
11
12namespace PSendFlag{
15 BLOCK, //Normal usage of the Socket. Blocking until a message is sent
16 NON_BLOCK //The Socket send does not stop the execution of the program
17 };
18}
19
20namespace PSendStatus{
23 OK, //Everything is OK
24 SOCKET_NOT_AVAILABLE, //The socket is not available
25 NO_ROUTE_TO_RECEIVER, //The receiver cannot be reached, maybe caused by network problem
26 SIGNAL_INTERRUPTION, //The socket caught a signal
27 BROKEN_BACKEND, //The backend is broken
28 BROKEN_SOCKET, //The socket is broken and cannot longer be used
29 CANNOT_SERIALIZE_DATA //The data cannot be serialized in the message
30 };
31}
32
33namespace PRecvFlag{
36 BLOCK, //Normal usage of the Socket. Blocking until a message comes
37 NON_BLOCK //The Socket recv does not stop the execution of the program
38 };
39}
40
41namespace PRecvStatus{
44 OK, //Everything is OK
45 NO_MESSAGE_RECEIVED, //No message was received
46 INVALID_MESSAGE, //The received message is invalid
47 SOCKET_NOT_AVAILABLE, //The socket is not available
48 SIGNAL_INTERRUPTION, //The socket caught a signal
49 BROKEN_BACKEND, //The backend is broken
50 BROKEN_SOCKET, //The socket is broken and cannot longer be used
51 CANNOT_DESERIALIZE_DATA //Cannot deserialize data
52 };
53}
54
58 std::string hostname;
60 size_t port;
62 int recvTimeOut{-1};
64 int sendTimeOut{-1};
65};
66
67//toString functions with overloading
68std::string toString(PSendFlag::PSendFlag flag);
69std::string toString(PSendStatus::PSendStatus status);
70std::string toString(PRecvFlag::PRecvFlag flag);
71std::string toString(PRecvStatus::PRecvStatus status);
72
73//fromString template function with specializations
74template<typename T>
75T fromString(const std::string& str);
76
77template<>
79
80template<>
82
83template<>
85
86template<>
88
89
91#define PHOENIX_ASSERT_EXCEPTION(X) {\
92 bool isWrongSend = false;\
93 try{\
94 X;\
95 }catch(...){\
96 isWrongSend = true;\
97 }\
98 data_stream_assert(isWrongSend);\
99}
100
101#endif
102
PRecvFlag::PRecvFlag fromString< PRecvFlag::PRecvFlag >(const std::string &str)
Convert a std::string into a PRecvFlag.
PRecvStatus::PRecvStatus fromString< PRecvStatus::PRecvStatus >(const std::string &str)
Convert a std::string into a PRecvStatus.
T fromString(const std::string &str)
std::string toString(PSendFlag::PSendFlag flag)
Convert a PSendFlag into a std::string.
PSendFlag::PSendFlag fromString< PSendFlag::PSendFlag >(const std::string &str)
Convert a std::string into a PSendFlag.
PSendStatus::PSendStatus fromString< PSendStatus::PSendStatus >(const std::string &str)
Convert a std::string into a PSendStatus.
PRecvFlag
describe the receiving flag of the Socket
Definition PSocketFlag.h:35
PRecvStatus
describe the result of the recv
Definition PSocketFlag.h:43
@ SIGNAL_INTERRUPTION
Definition PSocketFlag.h:48
@ CANNOT_DESERIALIZE_DATA
Definition PSocketFlag.h:51
@ NO_MESSAGE_RECEIVED
Definition PSocketFlag.h:45
@ SOCKET_NOT_AVAILABLE
Definition PSocketFlag.h:47
PSendFlag
describe the sending flag of the Socket
Definition PSocketFlag.h:14
PSendStatus
describe the result of the send
Definition PSocketFlag.h:22
@ SOCKET_NOT_AVAILABLE
Definition PSocketFlag.h:24
@ NO_ROUTE_TO_RECEIVER
Definition PSocketFlag.h:25
@ CANNOT_SERIALIZE_DATA
Definition PSocketFlag.h:29
@ SIGNAL_INTERRUPTION
Definition PSocketFlag.h:26
Parameters to create a socket.
Definition PSocketFlag.h:56
int sendTimeOut
Timeout of the send method.
Definition PSocketFlag.h:64
int recvTimeOut
Timeout of the recv method.
Definition PSocketFlag.h:62
std::string hostname
Name of the host to be connected to.
Definition PSocketFlag.h:58
size_t port
Port to be connected to.
Definition PSocketFlag.h:60