【发布时间】:2012-11-28 06:41:40
【问题描述】:
使用 Visual basic 6.0,我正在建立一个到 Web 服务器的 Winsock HTTP 连接,该连接发送数据并在之后立即关闭。 (连接:keep-alive,对这个服务器没有任何好处)
这是我的一段代码:
sck.SendData "GET /? HTTP/1.1" & vbNewLine & _
"Host: example.org" & vbNewLine & _
"Connection: keep-alive" & vbNewLine & vbNewLine
'// Wait for full Data:
Dim DATA As String
While (Not isEOF(DATA)) And sck.State = sckConnected
If sck.State = sckConnected Then sck.PeekData DATA
Sleep 10: DoEvents
Wend
If sck.State <> sckConnected Then
'// When this Fires, my data is missing the 25% of it's rest.
'// It is received corectly acording to Wireshark, but Winsock
'// closes the socket befor I can get the rest to the DATA variable.
MsgBox "This happends randomly 10% of the times.", vbInformation
End If
Clipboard.Clear
Clipboard.SetText DATA
Msgbox DATA
sck.Close
isEOF() 函数会检查数据是否已满并准备就绪(读取内容长度、