自己写的3

AskaRo2010 2010-11-22 06:31:00

#ifndef _CWEB_H_
#define _CWEB_H_

#include <string>
#include <list>

using namespace std;

#define WEB_DEFAULT_HTTP_PORT 80
#define WEB_DEFAULT_PROXY_PORT 8080

#define WEB_ERR_NULL 0x0000
#define WEB_ERR_CREATE_SOCK 0x0001
#define WEB_ERR_GET_IP 0x0002
#define WEB_ERR_CONNECT 0x0004


#define READ_UNCOMPRESS_ERR 0x0000
#define READ_TEXT_HTML 0x0001
#define READ_TEXT_CSS 0x0002
#define READ_IMAGE_JPEG 0x0004
#define READ_IMAGE_PNG 0x0008
#define READ_IMAGE_GIF 0x0010
#define READ_IMAGE_X_ICON 0x0020
#define READ_APPLICATION_JAVASCRIPT 0x0040
#define READ_APPLICATION_X_JAVASCRIPT 0x0080
#define READ_OTHERS 0x0100


#define CONTENT_TYPE_TEXT_HTML "text/html"
#define CONTENT_TYPE_TEXT_CSS "text/css"
#define CONTENT_TYPE_IMAGE_JPEG "image/jpeg"
#define CONTENT_TYPE_IMAGE_PNG "image/png"
#define CONTENT_TYPE_IMAGE_GIF "image/gif"
#define CONTENT_TYPE_IMAGE_X_ICON "image/x-icon"
#define CONTENT_TYPE_APPLICATION_JAVASCRIPT "application/javascript"
#define CONTENT_TYPE_APPLICATION_X_JAVASCRIPT "application/x-javascript"


#define MSG_ITEM_DATE "Date: "
#define MSG_ITEM_SERVER "Server: "
#define MSG_ITEM_CONTENT_TYPE "Content-Type: "
#define MSG_ITEM_CONTENT_ENCODING "Content-Encoding: "
#define MSG_ITEM_CONTENT_LENGTH "Content-Length: "
#define MSG_ITEM_TRANSFER_ENCODING "Transfer-Encoding: "
#define MSG_ITEM_CONNECTION "Connection: "
#define MSG_ITEM_CACHE_CONTROL "Cache-Control: "
#define MSG_ITEM_LAST_MODIFIED "Last-Modified: "
#define MSG_ITEM_EXPIRES "Expires: "
#define MSG_ITEM_PRAGMA "Pragma: "
#define MSG_ITEM_DPOOL_HEADER "DPOOL_HEADER: "
#define MSG_ITEM_VARY "Vary: "
#define MSG_ITEM_ACCEPT_RANGES "Accept-Ranges: "


class CCookie
{
public:
CCookie(const char* pStrCookie);
CCookie(const char* pStrKey, const char* pStrValue);
CCookie(const CCookie& cookie);
virtual ~CCookie();
public:
const char* GetKey();
const char* GetValue();
void SetValue(const char* pStrValue);
private:
CCookie();

private:
string m_strKey;
string m_strValue;
};

class CWeb
{
public:
CWeb();
virtual ~CWeb();
public:
void SetAgent(const char* pStrUserAgent);

static void SetProxy(const char* pStrProxyName, unsigned short usProxyPort = WEB_DEFAULT_PROXY_PORT);
int SetServer(const char* pStrServerName, unsigned short usServerPort = WEB_DEFAULT_HTTP_PORT);

void SetRequest
(
const char* pStrVerb,
const char* pStrObjName,
const char* pStrAccept,
const char* pStrReferer,
const char* pStrAcceptEncoding,
const char* pStrHeaders
);

const char* GetRequest();

int SendRequest();

int ReadData();

const char* GetMsg();

bool GetMsgItem(string& strItem,const char* pStrMsgItemKey);

const char* GetData();

unsigned long GetDataSize();

const char* GetHtml();

private:
CWeb(CWeb& obj);

const char* ReadMsg();
bool IsGzip();
bool CheckItem(const char* pStrMsgItemKey, const char* pStrMsgItemValue);
void ReadDataByLen(char* pBuf,unsigned long ulCurBufDataLen, unsigned long ulDestLen);
void SetCookie();
bool IsProxy();
int GetContentType();
private:
static unsigned int ms_uiWSAStartupCount;
static string ms_strProxy;
static unsigned short ms_usProxyPort;
string m_strHost;
unsigned short m_usHostPort;

string m_strUserAgent;

int m_sock;
void* m_pAddress;

string m_strRequest;

string m_strMsg;
char* m_pData;
unsigned long m_ulDataSize;

bool m_DataAndHtmlIsSynchronous;
string m_strHtml;

list<CCookie> m_cookieList;
};

#endif//_CWEB_H_
...全文
94 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ayw215 2010-11-22
  • 打赏
  • 举报
回复
http协议?
实现呢
内容概要:本文提出了一种针对大规模电动汽车接入电网的双层优化调度策略,并基于IEEE33节点系统进行了建模与仿真分析,配套提供了完整的Matlab代码实现。该策略构建了上层电网运行优化与下层电动汽车充电调度的双层协同模型,综合考虑电网负荷削峰填谷、电压稳定性维持以及电动汽车用户充电需求满足等多重目标,采用先进的优化算法实现对电动汽车集群的智能有序调度。研究详细阐述了双层模型的构建逻辑、目标函数设计、约束条件设定及迭代求解流程,有效降低了电网峰谷差,提升了配电系统对可再生能源的消纳能力,兼具扎实的理论深度与明确的工程应用前景。; 适合人群:电气工程、电力系统及其自动化、能源系统优化等相关专业的研究生、科研人员以及从事智能电网、电动汽车调度、分布式能源管理等领域工作的工程师和技术人员。; 使用场景及目标:①深入研究高比例电动汽车接入对配电网运行特性的影响机制;②掌握电力系统双层优化建模方法及其在实际系统中的求解技巧;③实现电动汽车集群的协同调度与车网互动(V2G)优化控制;④作为撰学术论文、开展课题研究或复现高水平期刊成果的技术参考与代码基础。; 阅读建议:建议读者结合所提供的Matlab代码逐行理解双层优化模型的数学表达与程序实现细节,重点剖析上下层模型之间的信息交互机制与收敛判据,可通过调整电动汽车渗透率、充电行为参数或引入分布式电源等场景进行拓展性仿真,以深化对智能调度策略适应性的认识。

15,446

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧