123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef __TCP_CLIENT_HEADER__
- #define __TCP_CLIENT_HEADER__
- #include "Global.h"
- #include <Ws2tcpip.h>
- #pragma comment(lib,"Ws2_32.lib")
- #pragma once
- #ifdef IRCONTROL_EXPORTS
- #define IRCONTROL_API __declspec(dllexport)
- #else
- #define IRCONTROL_API __declspec(dllimport)
- #endif
- class IRCONTROL_API CTCPClient
- {
- public:
- CTCPClient();
- ~CTCPClient();
-
- bool InitSocket();
-
- bool Connect(std::string ip, int port);
-
- bool SelectConnect(std::string ip, int port, int time_out = 3);
-
- void DisConnect();
-
- bool Send(std::string s_data, std::string &r_data);
-
- void ReConnect(DWORD dwError = WSAENETRESET);
- protected:
- bool checkEOM(std::string& data);
- private:
-
- SOCKET m_socket;
-
- sockaddr_in m_sin;
-
- std::string m_ip;
-
- int m_port;
- };
- #endif
|