This repository has been archived on 2021-11-25. You can view files and clone it, but cannot push or open issues/pull-requests.
JZFamily-HelloWorld/CWeatherDataSpider.h

54 lines
834 B
C++

//------------------------------------
//author: jidzh
//data; 2017-10-30
//------------------------------------
#pragma once
#include <string>
#include <WinSock2.h>
#ifdef DEBUG
#else
#endif // DEBUG
class CWeatherDataSpider
{
public:
CWeatherDataSpider();
~CWeatherDataSpider();
public:
std::string m_strAreaCode;
private:
//------------------------------------------------
SOCKET m_socket;
//WSADATA m_WSAdata;
private:
//----------------------------------------------------
//创建描述符
bool CreateWSAdata();
//连接主机
bool ConnectHost();
//发送请求
bool SendReq();
//处理回应
bool HandleAck();
//检查是否接收成功
bool CheckIfRecSucceed(char * buf, int nTotalRecv, int nFlag);
public:
bool GetWeatherDataXml();
void CloseConnect();
void ErrHandle(const std::wstring msg, int code = 0);
};