nattsurf123 0 Newbie Poster

Hi,
I have some problem receiving data with GetData after using post method. GetData returns nothing.
I have installed fiddler the ip-sniffer to se what happends. Fiddler seams to receive data without any problem for the request.

Appreciate your help.

Here is the code I use:

Dim retData As String
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub DoSleep()
Sleep (1000)
End Sub


Private Sub Winsock1_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
'Junk code for break point.
Dim dong As Long
dong = 5
End Sub



Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim Data As String
    Winsock1.GetData (Data)
    retData = retData & Data
    Dim x As Integer
    x = 5
    
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock1.Close
End Sub
Private Sub Submit_Click()
    'MsgBox (Me.ContentControls(1).Range.Text)
    retData = Empty
    Winsock1.Close

    If Winsock1.State = sckDisconnected Then
        Winsock1.RemoteHost = "127.0.0.1"
        'Winsock1.LocalPort = 8080

	'Set to 80 if you don't use ip sniffer.
        Winsock1.RemotePort = 8888
        Winsock1.Connect
        
        If Winsock1.State = sckDisconnected Then
            MsgBox ("Not connected")
        Else
            Dim abc As String
            abc = "test=34"
            For i = 0 To 5
                If Winsock1.State = sckConnected Then
                    Exit For
                End If
             DoSleep
             DoEvents
            Next
            
   
       
           
            'Winsock1.SendData ("POST /index.php HTTP/1.1")
            Winsock1.SendData ("POST /index.php HTTP/1.1" & vbCrLf & _
            "Host: " & "127.0.0.1" & ":80" & vbCrLf & vbCrLf)
            '"Content-Length: " & Len(abc) & vbCrLf & _
            '"Connection: Keep-Alive" & vbCrLf & _
            'vbCrLf & abc & vbCrLf)

            For i = 0 To 5
                If Len(retData) > 0 Then
                    Exit For
                End If
             DoSleep
             DoEvents
            Next

            
           'Winsock1.GetData (msg)
            'MsgBox (msg)
        End If
    End If
    
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.