文章分类 - VC++ 网络
摘要:本部分将向你展示如果使用WinPcap API的特性。它是以教程的方式来组织的,并细分为一系列的课程,以step-by-step的方式,向读者介绍如何利用WinPcap编程,从基本的功能(获取网卡列表,抓包等等)到最高级的功能(处理发送队列和收集网络流量统计数据)。代码片段以及一些简单但是完整的程序可供参考:所有源码都有指向使用手册的链接,即只要在函数或者数据结构上点击,就会跳到对应的文档。(译注:本译文暂不提供该功能)示例代码是用纯C写的,所以需要一些基本的C语言编程知识。同时,因为本教程需要使用一些函数库来处理“原生(raw)”网络包,因此假定你对网络和网络协议也比较熟悉。1. 获取设备列
阅读全文
摘要:[转:http://support.microsoft.com/kb/168151]使用 WinInet API 可以建立安全套接字层 (SSL) 或专用通信技术 (PCT) HTTP 会话。安全 HTTP(表示为 HTTPS://)在 TCP 端口 443 上发生。可以使用类似于下面这样的代码来建立 HTTPS 会话: ... hOpen = InternetOpen (...); Connect = InternetConnect (hOpen,// InternetOpen handle"MyHttpServer", // ServernameINTERNET_DEF
阅读全文
摘要:void httpTest(){ HINTERNET m_hInternet = InternetOpen( L"My Agent",//agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); HINTERNET m_hSession = InternetConnect( m_hInternet, (LPCWSTR)L"www.baidu.com",//把协议去了,只要url,还有宽字符 L 你也漏了, INTERNET_DEFAULT_HTTP_PORT, L"", L"&
阅读全文
摘要:CInternetSession stInternet; CHttpConnection* stConn = stInternet.GetHttpConnection("nexus.passport.com",INTERNET_FLAG_SECURE,443,"",""); CHttpFile* httpFile = stConn->OpenRequest("GET","/rdr/pprdr.asp",0,1,0,"1.0",INTERNET_FLAG_SECURE);
阅读全文
摘要:pIS = new CInternetSession();EXIT_ON_NULL(pIS,hr);pHC = pIS->GetHttpConnection(strUrl,INTERNET_FLAG_SECURE,0,0,0);TracklogA("pIS->GetHttpConnection %d",hr);EXIT_ON_NULL(pHC,hr); pHF = pHC->OpenRequest(CHttpConnection::HTTP_VERB_POST,sHrefLianXiRen,0,1,0,0,INTERNET_FLAG_SECURE);Tra
阅读全文
摘要:转自:http://blog.csdn.net/jinhill/article/details/7321515#include "StdAfx.h"#include <afxinet.h>CInternetSession *g_ISession;CHttpConnection *g_pHttpConn = NULL;CHttpFile *g_pHttpFile = NULL;const char g_szHeaders[]=_T("Accept: */*\r\nUser-Agent:Jinhill Http Agent\r\nContent-Type:
阅读全文
摘要:本程序用C++语言实现了HTTP协议的请求消息,包括GET,POST方法,在windows下编译通过,可以运行。-This procedure using C++ language implementation of the HTTP protocol' s request message, including GET, POST method, compiled through the windows, you can run.http://www.pudn.com/downloads213/sourcecode/windows/detail1004323.html下面这三个是什么关
阅读全文
摘要:1. CInternetSession的简单使用CInternetSession session;CHttpFile *file = NULL; CString strURL = " http://www.20abcd.com";CString strHtml = "”; //存放网页数据try{ file = (CHttpFile*)session.OpenURL(strURL);}catch(CInternetException * m_pException){ file = NULL; m_pException->m_dwError; m_pExcep
阅读全文
摘要:void CWinInetDlg::OnOK() {CInternetSession Sess;CHttpConnection* HttpCon = NULL;CHttpFile* pFile = NULL;HttpCon = Sess.GetHttpConnection(_T("www.sogou.com")); //这里的网址不能加http:// ,像这样写是错的 http://www.sogou.com/pFile =HttpCon->OpenRequest("GET",""); //这里的GET要大写,如果写成Get 或
阅读全文
摘要:CString strHeaders =_T("Content-Type: application/x-www-form-urlencoded\r\n"); CInternetSession session; CHttpConnection* pConnection =session.GetHttpConnection("127.0.0.1",(INTERNET_PORT)80); //与服务器建立连接; CHttpFile* pFile =pConnection->OpenRequest(CHttpConnection::HTTP_VERB_PO
阅读全文
摘要:id="Topic_"想用发送request的方式在程序中获得网页的源代码OpenRequest和AddRequestHeaders参数要怎么填,最好举sina主页为例说明下?比如下面几个空着的参数怎么填?CInternetSessionsession;session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,30*1000);session.SetOption(INTERNET_OPTION_CONNECT_BACKOFF,1000);session.SetOption(INTERNET_OPTION_CONNECT_RETRIE
阅读全文
摘要:转自:http://hi.baidu.com/5iprog/blog/item/4f83dbb00c1f3243092302e5.htmlCHttpConnection::OpenRequestCHttpFile* OpenRequest( LPCTSTR pstrVerb, LPCTSTR pstrObjectname, LPCTSTR pstrReferer = NULL, DWORD dwContext = 1, LPCTSTR* pstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL, DWORD dwFlags = INTERNET_FL
阅读全文
摘要:可以尝试通过 HttpAddRequestHeaders 来添加自已的COOKIE:char * lpszHeaders = "Cookie: Key=somevalue";DWORD dwHeadersLength = strlen(lpszHeaders);HttpAddRequestHeaders(hOpenRequest, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD); 函数会返回成功,但实际上COOKIE可能并没有添加上去,建议在调用HttpOpenRequest时指定 INTERNET_FLAG_NO_C
阅读全文