📄 downloadsocket.h
字号:
/*
socket基类,所有协议类从该类继承
*/
#pragma once
#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
#include <winsock2.h>
#include <WS2TCPIP.H> //for ipv6
#pragma comment(lib, "ws2_32.lib")
#endif
#include <TCHAR.H>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "stateCode.h"
class CDownloadSocket
{
protected:
SOCKET m_socket;
TCHAR m_lpszHost[128];//static
UINT m_port;//static
TCHAR m_lpszUrl[1024];
public:
CDownloadSocket(void);
~CDownloadSocket(void);
bool CheckDll();//检测ws2_32.lib正确性
bool IniSocket();//初始化
bool Connect( LPTSTR host,UINT port );//建立 网络连接
virtual void Login()=0;
int Send(LPTSTR buf) ;//
int Recv(LPTSTR buf,int len) ;
void SetUrl(LPCTSTR lpszUrl);
virtual void SetOffset(int offset) = 0;
virtual int SendRequest(LPTSTR buf,UINT begin =0,UINT end = 0) = 0;
virtual int RecvData(LPTSTR buf) = 0;//得到文件数据,放在buf里
virtual void CloseSocket()=0;
virtual UINT GetContentLen(LPCTSTR buf) = 0;
virtual UINT GetHeaderLen(LPCTSTR buf) = 0;
virtual void IgnoreIpHeader(LPTSTR buf) = 0;
virtual RESPONSECODE GetResponse(LPCTSTR buf)= 0;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -