社区
网络编程
帖子详情
急!!!高分请教,InternetOpen怎么使用socks代理。
huang_yi_cn
2005-05-07 04:35:52
如题,谢谢!
...全文
736
13
打赏
收藏
急!!!高分请教,InternetOpen怎么使用socks代理。
如题,谢谢!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jerry
2005-05-09
打赏
举报
回复
我慢慢看看... 我开一帖给你分.
楼主去接分:
http://community.csdn.net/Expert/topic/3990/3990681.xml?temp=.7436945
fisker0303
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
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-get-.zip_
Internet
Open
_
Internet
Open
Url_
internet
readfile
Internet
Open
第一的WinINet
使用
初始化函数,然后用
Internet
Open
Url打开指定的链接,并最终能够读取与
Internet
ReadFile的网页源代码。
易语言密码
代理
验证模块
易语言密码
代理
验证模块源码,密码
代理
验证模块,密码
代理
验证,取域名,取端口,取页面地址,API_
Internet
Open
,API_
Internet
Connect,API_Http
Open
Request,API_HttpSendRequest,API_HttpQueryInfo,API_
Internet
CloseHandle
多线程下载源程序MFC提供的WinInet类
本程序主要演示了MFC WinInet编程的基本思想。WinInet API是一个函数集,利用这些函数,可以编写面向
Internet
的应用程序,而不用考虑基本的通信协议(FTP,HTTP),MFC提供的WinInet类是对WinInet API函数封装而成。
基于WinInet实现HTTP文件上传小程序
使用
Internet
Open
建立会话,获取会话句柄
使用
Internet
Connect 与网站建立连接,获取连接句柄 设置HTTP的访问标志,
使用
Http
Open
Request 打开HTTP的“POST”请求 构造请求信息头字符串,并
使用
...
网络编程
18,356
社区成员
64,214
社区内容
发帖
与我相关
我的任务
网络编程
VC/MFC 网络编程
复制链接
扫一扫
分享
社区描述
VC/MFC 网络编程
c++
c语言
开发语言
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章