#pragma once #include #include #include #include #include #include #ifdef _WIN32 #define _WINSOCK_DEPRECATED_NO_WARNINGS #include #else #include #include #endif typedef std::function UdpClientRecvDataFunc; class IYUDPClient { public: virtual ~IYUDPClient() = default; // 创建对象 static bool CreateUDPClient(IYUDPClient** ppIUDPClient); /** * 初始化服务 * @brief Init * @return */ virtual int Init(const bool bBoard) = 0; /** * 开始接收UDP数据 * @brief StartUDPClient * @return */ virtual int StartUDPClient(UdpClientRecvDataFunc pRecvDataFunc) = 0; /** * 结束接收UDP数据 * @brief StopUDPClient * @return */ virtual int StopUDPClient() = 0; /** * 发送数据 * @brief SendData * @param pData * @param nLen * @return */ virtual int SendData(const int nPort, const char* pAddr, const char* pData, const int nLen) = 0; };