社区
网络编程
帖子详情
急!!!高分请教,InternetOpen怎么使用socks代理。
huang_yi_cn
2005-05-07 04:35:52
如题,谢谢!
...全文
753
13
打赏
收藏
急!!!高分请教,InternetOpen怎么使用socks代理。
如题,谢谢!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jerry
2005-05-09
打赏
举报
回复
我慢慢看看... 我开一帖给你分.
楼主去接分:
http://community.csdn.net/Expert/topic/3990/3990681.xml?temp=.7436945
菲斯可儿
2005-05-08
打赏
举报
回复
恩,学习。
huang_yi_cn
2005-05-08
打赏
举报
回复
我找到答案了, 来此跟大家分享一下吧:
1. 相关函数:
HINTERNET WINAPI InternetOpen(
LPCTSTR lpszAgent,
DWORD dwAccessType,
LPCTSTR lpszProxy,
LPCTSTR lpszProxyBypass,
DWORD dwFlags);
BOOL WINAPI InternetSetOption(
HINTERNET hInternet,
DWORD dwOption,
LPVOID lpBuffer,
DWORD dwBufferLength);
2. 相关结构
typedef struct {
DWORD dwAccessType;
LPCTSTR lpszProxy;
LPCTSTR lpszProxyBypass;
} INTERNET_PROXY_INFO, *LPINTERNET_PROXY_INFO;
3. 使用代理服务器
(1)请将dwAccessType设置成INTERNET_OPEN_TYPE_PROXY
(2)设置lpszProxy
(a)代理的格式必须为:[<protocol>=][<scheme>://]<proxy>[:<port>].
(b)其中protocol, scheme://, :port是可选项, 如果忽略这三者, 则它们默认分别为
HTTP, HTTP://, :80. 即默认为HTTP代理.
(c)多个代理必须使用" "(空格)隔开
(d)各种常用代理的使用见如下:
HTTP:
HTTP=HTTP://proxyserver:port
FTP:
FTP:FTP://proxyserver:port
GOPHER
GOPHER=HTTP://proxyserver:port
SOCKS=proxyserver:port
其中前三种都可以在msdn中找到, 但第四种我可是找了N多地方才好不容易找到了. 另外要注意, msdn中明确说明只有安装了IE才能使用SOCKS代理.
louifox
2005-05-08
打赏
举报
回复
学习
huang_yi_cn
2005-05-08
打赏
举报
回复
别忘了给分哟, 呵呵呵
huang_yi_cn
2005-05-08
打赏
举报
回复
详细说明请见msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/handling_authentication.asp
huang_yi_cn
2005-05-08
打赏
举报
回复
这段代码就是设置代理的用户名和密码的呀, 其中INTERNET_OPTION_USERNAME设置代理服务器的用户名, INTERNET_OPTION_PASSWORD设置相应的密码.
删繁就简, 如果只是纯粹的设置用户名和密码, 只需要下面的代码就可以了.
InternetSetOption(hResourceHandle, INTERNET_OPTION_USERNAME,
strUsername, cchUserLength+1);
InternetSetOption(hResourceHandle, INTERNET_OPTION_PASSWORD,
strPassword, cchPasswordLength+1);
其中strUsername设置用户名, strPassword指定密码.
jerry
2005-05-08
打赏
举报
回复
这段代码好象跟代理没什么关系呀!
huang_yi_cn
2005-05-08
打赏
举报
回复
The following example code shows how authentication could be handled using InternetSetOption.
HINTERNET hOpenHandle, hResourceHandle;
DWORD dwError, dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);
char strUsername[64], strPassword[64];
hOpenHandle = InternetOpen("Example",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0);
hConnectHandle = InternetConnect(hOpenHandle,
"www.server.com",
INTERNET_INVALID_PORT_NUMBER,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,0);
hResourceHandle = HttpOpenRequest(hConnectHandle, "GET",
"/premium/default.htm",
NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION,
0);
resend:
HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);
HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER |
HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL);
switch (dwStatus)
{
case HTTP_STATUS_PROXY_AUTH_REQ: // Proxy Authentication Required
// Insert code to set strUsername and strPassword.
// cchUserLength is the length of strUsername and
// cchPasswordLength is the length of strPassword.
DWORD cchUserLength, cchPasswordLength;
// Insert code to safely determine cchUserLength and
// cchPasswordLength. Insert appropriate error handling code.
InternetSetOption(hResourceHandle,
INTERNET_OPTION_PROXY_USERNAME,
strUsername,
cchUserLength+1);
InternetSetOption(hResourceHandle,
INTERNET_OPTION_PROXY_PASSWORD,
strPassword,
cchPasswordLength+1);
goto resend;
break;
case HTTP_STATUS_DENIED: // Server Authentication Required.
// Insert code to set strUsername and strPassword.
// cchUserLength is the length of strUsername and
// cchPasswordLength is the length of strPassword.
DWORD cchUserLength, cchPasswordLength;
// Insert code to safely determine cchUserLength and
// cchPasswordLength. Insert error handling code as
// appropriate.
InternetSetOption(hResourceHandle, INTERNET_OPTION_USERNAME,
strUsername, cchUserLength+1);
InternetSetOption(hResourceHandle, INTERNET_OPTION_PASSWORD,
strPassword, cchPasswordLength+1);
goto resend;
break;
}
// Insert code to read the data from the hResourceHandle
// at this point.
给分, 哈哈
jerry
2005-05-08
打赏
举报
回复
楼主,怎么区分SOCK4/SOCK5代理?
SOCK5代理一般还需要身份认证的.
我分很多,多给你分.
能说详细一点吗?
jerry
2005-05-08
打赏
举报
回复
收藏!
jerry
2005-05-07
打赏
举报
回复
这个我也想知道!~
hai_feng
2005-05-07
打赏
举报
回复
up
wininet-get-.zip_
Internet
Open
_
Internet
Open
Url_
internet
readfile
Internet
Open
第一的WinINet
使用
初始化函数,然后用
Internet
Open
Url打开指定的链接,并最终能够读取与
Internet
ReadFile的网页源代码。
VC程序添加
代理
设置
VC程序添加
代理
设置 By Koma http://blog.csdn.net/wangningyu
HTTP AND FTP AND HTIPS 下载例子
internet
Open
.rar
HTTP AND FTP AND HTIPS 下载例子
internet
Open
.rarHTTP AND FTP AND HTIPS 下载例子
internet
Open
.rarHTTP AND FTP AND HTIPS 下载例子
internet
Open
.rarHTTP AND FTP AND HTIPS 下载例子
internet
Open
.rar
基于wininet下的HTTP访问之
代理
服务器 源代码
基于wininet技术集合c++写的源代码,可以实现用
代理
服务器来访问URL页面,不是vc++,所以页面显示只是HTML的源代码。zhaquanmin@163.com
易语言密码
代理
验证模块
易语言密码
代理
验证模块源码,密码
代理
验证模块,密码
代理
验证,取域名,取端口,取页面地址,API_
Internet
Open
,API_
Internet
Connect,API_Http
Open
Request,API_HttpSendRequest,API_HttpQueryInfo,API_
Internet
CloseHandle
网络编程
18,363
社区成员
64,187
社区内容
发帖
与我相关
我的任务
网络编程
VC/MFC 网络编程
复制链接
扫一扫
分享
社区描述
VC/MFC 网络编程
c++
c语言
开发语言
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章