Okay so I'm a little bit confused as to why I can't fix my problem -the thing is I have a tcpclient and I want to make http requests using it - I type the IP address of the target server and it's port which is 80 it all works fine when I'm requesting a page it's just I can't figure out how to get the full response for any image which I try to get, for example if I make a request for Google's favicon using the following:
It tells me the content length but not the actual content - How do I get the content???
Below is my code.
I hope someone can help me - thanks.
the response which I'm given by the server is just:GET /favicon.ico HTTP/1.1
Host: www.google.co.uk
HTTP/1.1 200 OK
Content-Type: image/x-icon
Last-Modified: Fri, 30 May 2008 06:03:19 GMT
Expires: Sun, 17 Jan 2038 19:14:07 GMT
Date: Wed, 11 Jun 2008 12:46:08 GMT
Server: gws
Content-Length: 1150
It tells me the content length but not the actual content - How do I get the content???
Below is my code.
VB.NET:
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(TextBox1.Text, TextBox2.Text)
Dim networkStream As Net.Sockets.NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.UTF8.GetBytes(RichTextBox2.Text)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.UTF8.GetString(bytes)
MsgBox(returndata)
End If
Last edited by a moderator: