22 #ifndef MYTHPROTOBASE_H 23 #define MYTHPROTOBASE_H 25 #include "../mythtypes.h" 29 #define PROTO_BUFFER_SIZE 4000 30 #define PROTO_SENDMSG_MAXSIZE 64000 31 #define PROTO_STR_SEPARATOR "[]:[]" 32 #define PROTO_STR_SEPARATOR_LEN (sizeof(PROTO_STR_SEPARATOR) - 1) 47 ProtoBase(
const std::string& server,
unsigned port);
53 ERROR_SERVER_UNREACHABLE,
55 ERROR_UNKNOWN_VERSION,
58 virtual bool Open() = 0;
60 virtual bool IsOpen() {
return m_isOpen; }
61 virtual unsigned GetProtoVersion()
const;
62 virtual std::string GetServer()
const;
63 virtual unsigned GetPort()
const;
64 virtual int GetSocketErrNo()
const;
65 virtual int GetSocket()
const;
66 virtual bool HasHanging()
const;
67 virtual void CleanHanging();
68 virtual ERROR_t GetProtoError()
const;
73 unsigned m_protoVersion;
81 bool OpenConnection(
int rcvbuf);
83 bool SendCommand(
const char *cmd,
bool feedback =
true);
84 size_t GetMessageLength()
const;
85 bool ReadField(std::string& field);
86 bool IsMessageOK(
const std::string& field)
const;
87 size_t FlushMessage();
88 bool RcvMessageLength();
90 ProgramPtr RcvProgramInfo()
92 if (m_protoVersion >= 86)
return RcvProgramInfo86();
93 if (m_protoVersion >= 82)
return RcvProgramInfo82();
94 if (m_protoVersion >= 79)
return RcvProgramInfo79();
95 if (m_protoVersion >= 76)
return RcvProgramInfo76();
96 return RcvProgramInfo75();
99 void MakeProgramInfo(
const Program& program, std::string& msg)
101 if (m_protoVersion >= 86) MakeProgramInfo86(program, msg);
102 else if (m_protoVersion >= 82) MakeProgramInfo82(program, msg);
103 else if (m_protoVersion >= 79) MakeProgramInfo79(program, msg);
104 else if (m_protoVersion >= 76) MakeProgramInfo76(program, msg);
105 else MakeProgramInfo75(program, msg);
110 ERROR_t m_protoError;
112 bool RcvVersion(
unsigned *version);
114 ProgramPtr RcvProgramInfo75();
115 ProgramPtr RcvProgramInfo76();
116 ProgramPtr RcvProgramInfo79();
117 ProgramPtr RcvProgramInfo82();
118 ProgramPtr RcvProgramInfo86();
119 void MakeProgramInfo75(
const Program& program, std::string& msg);
120 void MakeProgramInfo76(
const Program& program, std::string& msg);
121 void MakeProgramInfo79(
const Program& program, std::string& msg);
122 void MakeProgramInfo82(
const Program& program, std::string& msg);
123 void MakeProgramInfo86(
const Program& program, std::string& msg);
bool m_hang
Connection hang: while true allow retry.
This is the main namespace that encloses all public classes.
bool m_tainted
Connection has hung since last reset.