Winsock getdata after post method

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 7
Reputation: nattsurf123 is an unknown quantity at this point 
Solved Threads: 0
nattsurf123 nattsurf123 is offline Offline
Newbie Poster

Winsock getdata after post method

 
0
  #1
Jun 25th, 2009
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:
  1. Dim retData As String
  2. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  3.  
  4. Private Sub DoSleep()
  5. Sleep (1000)
  6. End Sub
  7.  
  8.  
  9. Private Sub Winsock1_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
  10. 'Junk code for break point.
  11. Dim dong As Long
  12. dong = 5
  13. End Sub
  14.  
  15.  
  16.  
  17. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  18. Dim Data As String
  19. Winsock1.GetData (Data)
  20. retData = retData & Data
  21. Dim x As Integer
  22. x = 5
  23.  
  24. End Sub
  25. 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)
  26. Winsock1.Close
  27. End Sub
  28. Private Sub Submit_Click()
  29. 'MsgBox (Me.ContentControls(1).Range.Text)
  30. retData = Empty
  31. Winsock1.Close
  32.  
  33. If Winsock1.State = sckDisconnected Then
  34. Winsock1.RemoteHost = "127.0.0.1"
  35. 'Winsock1.LocalPort = 8080
  36.  
  37. 'Set to 80 if you don't use ip sniffer.
  38. Winsock1.RemotePort = 8888
  39. Winsock1.Connect
  40.  
  41. If Winsock1.State = sckDisconnected Then
  42. MsgBox ("Not connected")
  43. Else
  44. Dim abc As String
  45. abc = "test=34"
  46. For i = 0 To 5
  47. If Winsock1.State = sckConnected Then
  48. Exit For
  49. End If
  50. DoSleep
  51. DoEvents
  52. Next
  53.  
  54.  
  55.  
  56.  
  57. 'Winsock1.SendData ("POST /index.php HTTP/1.1")
  58. Winsock1.SendData ("POST /index.php HTTP/1.1" & vbCrLf & _
  59. "Host: " & "127.0.0.1" & ":80" & vbCrLf & vbCrLf)
  60. '"Content-Length: " & Len(abc) & vbCrLf & _
  61. '"Connection: Keep-Alive" & vbCrLf & _
  62. 'vbCrLf & abc & vbCrLf)
  63.  
  64. For i = 0 To 5
  65. If Len(retData) > 0 Then
  66. Exit For
  67. End If
  68. DoSleep
  69. DoEvents
  70. Next
  71.  
  72.  
  73. 'Winsock1.GetData (msg)
  74. 'MsgBox (msg)
  75. End If
  76. End If
  77.  
  78. End Sub
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC