winsock控件编程
我试图发送一个请求,返回一个页面源文件,我用抓包工具提取了发送时的发送请求,但用vb编写的时候出现以下错误:
实时错误‘10037’:
The operation is completed.No blocking operation is in progress
我要返回的是www.51cha.com这个页面,源程序如下:
Private Sub Command1_Click()
Dim str As String
str = "GET / HTTP/1.1" & Chr(13) & Chr(10)
str = str & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*" & Chr(13) & Chr(10)
str = str & "Accept-Language: zh-cn" & Chr(13) & Chr(10)
str = str & "Accept-Encoding: gzip, deflate" & Chr(13) & Chr(10)
str = str & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" & Chr(13) & Chr(10)
str = str & "Host: www.51cha.com" & Chr(13) & Chr(10)
str = str & "Connection: Keep-Alive" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Chr(13) & Chr(10)
winsock.Connect
winsock.Listen
winsock.SendData str
winsock.GetData Text2.Text
winsock.Close
End Sub
其中,抓包得到的请求为:
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.51cha.com
Connection: Keep-Alive
请问是如何出错的?
问题点数:20、回复次数:2Top
1 楼homezj(小吉)回复于 2005-05-07 21:52:06 得分 20
你的winsock用法完全不对,看看下面的例子就会了:
http://community.csdn.net/Expert/topic/3916/3916595.xml?temp=.3020594Top
2 楼eiko1984(晓珺)回复于 2005-05-08 21:47:12 得分 0
哦,差不多看懂了,我重新试试
非常感谢~~Top




