I'm writing a program in VB6 using the winsock control. I'm using the winsock to request data from a php script that returns an answer in base64.
When I punch-in the request in my web browser the entire message is received (around 700,000+ characters). However when I do the request via my winsock control in VB6 I receive the firs packet of the response (around 7,000 characters). I read somewhere that HTTP 1.1 send in chunks not familiar with this.
If any knows why this is occurring please assist me with resolving it or point me in a direction that will help me understand how to resolve this issue?
Thanks in advance
j3rg
Edit:
=====
But anyway with more research I found the following links that might help:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21977116.html[
^]
http://www.xtremevbtalk.com/showthread.php?t=248347[
^]
In the meantime I'll keep researching.
Cheers
j3rg
Edit
====
OK Richard thank you ...Sorry I didn't notice your comment. Yes I figured there was more information to be received but I was wondering how to go about receiving the rest as in tell the server that I need the rest of the message/data. The link above from expert exchange gave me some help with this. A user form their forum posted the following code:
Private Sub WskServer_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim sWork As String
Dim sData As String
Dim lRecv As Long
Debug.Print "New data arrival detected @" & Time()
Debug.Print "Begin receiving new data from (" & bytesTotal & " total bytes)"
Debug.Print "Analyzing the current data block for terminating characters"
Do While True
DoEvents
WskServer(Index).PeekData sWork, vbString
If InStr(sWork, vbCrLf) Then
Exit Do
End If
Loop
lRecv = WskServer(Index).BytesReceived
Debug.Print "Retrieving the final data into our data variable (received " & lRecv & " of " & bytesTotal & " bytes)"
WskServer(Index).GetData sData, vbString
End Sub
Mine is basically the same thing with slight modification:
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim sWork As String
Dim sData As String
Dim lRecv As Long
Debug.Print "New data arrival detected @" & Time()
Debug.Print "Begin receiving new data from (" & bytesTotal & " total bytes)"
Debug.Print "Analyzing the current data block for terminating characters"
Do While True
DoEvents
Winsock.PeekData sWork, vbString
If InStr(sWork, Chr(255)) Then
Exit Do
End If
Loop
lRecv = Winsock.BytesReceived
Debug.Print "Retrieving the final data into our data variable (received " & lRecv & " of " & bytesTotal & " bytes)"
Winsock.GetData sData, vbString
Text1.Text = sData
End Sub
The difference is just that I'm not using a winsock control array, I check for ASCII character 255 and I'm appending the responses from the request into a text box.
When I execute my code I get the following run-time error "40006 - Wrong protocol or connection state for the requested transaction or request". I know this error is occurring due to the connection being close before another execution of the .PeekData again and this is caused due to the DoEvents in the code. The DoEvents seems necessary through my testing of the code.
The expert exchange link address this issue and I am currently looking at that.
And about the vote I just didn't like the idea of rating it low and not saying why that's dumb. But as you say don't worry about it so you're right I just don't give a F*** about them and I say them because its 2 now LMAO.
Thank you for your assistance
j3rg