/***************************************************************************** * @Descripttion: * @Author: FengChao * @Date: 2020-08-07 16:56:44 * @LastEditors: LastEditors * @LastEditTime: 2020-08-07 17:29:41 *****************************************************************************/ /************************************************************************* > File Name : CZeroMQ.h > Author : FengChao > EMail : smile.fengchao@gmail.com > Created Time : Fri 17 Jul 2020 09:30:51 AM CST ************************************************************************/ #ifndef CZEROMQ_H #define CZEROMQ_H #include class CZMQSubscriber { public: explicit CZMQSubscriber(const char *pcAddrPort, const char *pcPriKey = NULL, const char *pcPubKey = NULL); ~CZMQSubscriber(); int SetRecvTimeout(unsigned int uiSeconds = 3); int RecvData(void *pvBuff, unsigned int uiBuffLen); private: int SocketInit(); private: void *m_pvSubCtx; void *m_pvSubSock; std::string m_strAddrPort; std::string m_StrPriKey; std::string m_StrPubKey; }; class CZMQReqRep { public: explicit CZMQReqRep(int iType, const char *pcAddrPort, const char *pcPriKey = NULL, const char *pcPubKey = NULL); ~CZMQReqRep(); int RecvData(void *pvBuff, unsigned int uiBuffLen); int SendData(const void *pvData, unsigned int uiDataLen); int SetRecvTimeout(unsigned int uiSeconds = 3); int SetSendTimeout(unsigned int uiSeconds = 3); private: int SocketInit(); private: int m_iType; void *m_pvCtx; void *m_pvSock; std::string m_strAddrPort; std::string m_StrPriKey; std::string m_StrPubKey; }; #endif /*CZEROMQ_H*/