报错:实时错误‘40006’
所需的事物或请求的错误协议或连接状态怎么解决啊?我看了很多相关的内容!#######################################################
Private Sub Command1_Click()winSock.Protocol = sckTCPProtocol
winSock.RemoteHost = "127.0.0.1"
winSock.RemotePort = 80
winSock.ConnectDim s As String
s = "GET / HTTP/1.0" + vbCrLf
s = s + "Accept:*/*" + vbCrLf
s = s + "Accept -Encoding: gzip, deflate" + vbCrLf
s = s + "User-Agent:Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.2;)" + vbCrLf
s = s + "Pragma:no-cache" + vbCrLf
s = s + "Cache-Control:no-cache" + vbCrLf
s = s_vbcrlf
winSock.SendData s
MsgBox "test"End SubPrivate Sub winSock_DataArrival(ByVal bytesTotal As Long)
Dim strcontent As String
winSock.GetData strcontent, vbString, bytesTotal
Text1.Text = Text1.Text + strcontentEnd Sub
######################################################
所需的事物或请求的错误协议或连接状态怎么解决啊?我看了很多相关的内容!#######################################################
Private Sub Command1_Click()winSock.Protocol = sckTCPProtocol
winSock.RemoteHost = "127.0.0.1"
winSock.RemotePort = 80
winSock.ConnectDim s As String
s = "GET / HTTP/1.0" + vbCrLf
s = s + "Accept:*/*" + vbCrLf
s = s + "Accept -Encoding: gzip, deflate" + vbCrLf
s = s + "User-Agent:Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.2;)" + vbCrLf
s = s + "Pragma:no-cache" + vbCrLf
s = s + "Cache-Control:no-cache" + vbCrLf
s = s_vbcrlf
winSock.SendData s
MsgBox "test"End SubPrivate Sub winSock_DataArrival(ByVal bytesTotal As Long)
Dim strcontent As String
winSock.GetData strcontent, vbString, bytesTotal
Text1.Text = Text1.Text + strcontentEnd Sub
######################################################
for i=0 to 500
doevents
next
Dim s As String
s = "GET / HTTP/1.0" + vbCrLf
s = s + "Accept:*/*" + vbCrLf
s = s + "Accept -Encoding: gzip, deflate" + vbCrLf
s = s + "User-Agent:Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.2;)" + vbCrLf
s = s + "Pragma:no-cache" + vbCrLf
s = s + "Cache-Control:no-cache" + vbCrLf
s = s_vbcrlf
winSock.SendData s
MsgBox "test"
因为winSock.Connect以后需要时间连接 不能马上执行winSock.SendData s
2中解决 1 循环等待 2 connect事件
Winsock.Protocol = sckTCPProtocol
Winsock.RemoteHost = "127.0.0.1"
Winsock.RemotePort = 80
Winsock.Connect
End SubPrivate Sub Winsock_Connect()
Dim s As String
s = "GET / HTTP/1.0" + vbCrLf
s = s + "Accept:*/*" + vbCrLf
s = s + "Accept -Encoding: gzip, deflate" + vbCrLf
s = s + "User-Agent:Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.2;)" + vbCrLf
s = s + "Pragma:no-cache" + vbCrLf
s = s + "Cache-Control:no-cache" + vbCrLf
s = s_vbcrlf
Winsock.SendData s
MsgBox "test"
End Sub