Hi,

Im trying to use the following socket code to send an http request and get a reply from google. However nothing is coming back, the app just freezes.
Any idea where i'm doing it wrong thanks?


vb Code:
  1. sender2.Connect("google.com", 80)
  2.  
  3.         TextBox2.Text = ("Socket connected to {0}" & sender2.RemoteEndPoint.ToString())
  4.  
  5.         ' Encode the data string into a byte array.
  6.         Dim msg As String = ("POST / HTTP/1.1 \r\n" & Environment.NewLine & _
  7. "Host: google.com \r\n" & Environment.NewLine & _
  8. "Accept: */* \r\n>" & Environment.NewLine & _
  9. "Content-Type: text/html \r\n" & Environment.NewLine & _
  10. "Content-Length: 0 \r\n" & Environment.NewLine)
  11.  
  12.         ' Send the data through the socket.
  13.         Dim bytesSent As Integer = sender2.Send(Encoding.ASCII.GetBytes(msg))
  14.  
  15.         TextBox1.Text = msg
  16.  
  17.         ' Receive the response from the remote device.
  18.         Dim bytesRec As Integer = sender2.Receive(bytes)
  19.  
  20.         TextBox2.Text = ("Echoed test = {0}" & Encoding.ASCII.GetString(bytes, 0, bytesRec))
  21.  
  22.         ' Release the socket.
  23.         sender2.Shutdown(SocketShutdown.Both)
  24.         sender2.Close()
  25.         sender2 = Nothing


Thanks