|
-
Jun 17th, 2008, 11:54 AM
#1
Thread Starter
New Member
[2008] HTTP with Tcpclient
Hi there, I have a problem that I'm hoping someone may be able to help me fix. I have a TCPlistener which I'm trying to make HTTP requests with and it works great if I'm making a request for a web page - the server returns the header and page content but I'm having a problem with getting the content of images - all I receive is the header saying which is giving me the OK but I cannot figure why the content isn't coming through.
Below is my code which makes a request for Google's favicon...
Dim tcpClient As New System.Net.Sockets.TcpClient()
Dim ip As String = "66.249.91.103"
Dim port As Integer = 80
tcpClient.Connect(ip, port)
Dim networkStream As Net.Sockets.NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.UTF8.GetBytes("GET /favicon.ico HTTP/1.1" & vbCrLf & "Host: www.google.co.uk" & vbCrLf & vbCrLf)
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
I hope someone could point out something I'm doing wrong or suggest additional help - I know that there are specific classes for this sort of thing, for example the webrequest one but that isn't really what I'm looking for.
Thanks for having a look.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|