what's the difference between "host" and" .RemoteHost "
HI,everybuddy
When I use winsock, I can't understand what's the difference between ".RemoteHost" & "Host"?
---------------------------------------------------
Private Sub Command1_Click()
With Winsock1
.Close
.RemoteHost = "www.vbfirums.com" ''''''''''''''''''here
.RemotePort = 80
.Connect
End With
End Sub
Private Sub Winsock1_Connect()
Dim s As String
s = "GET / HTTP/1.0" + vbCrLf
s = s + "Accept: */*" + vbCrLf
s = s + "Accept -Encoding: gzip , deflate" + vbCrLf
s = s & "Pragma: no-cache" & vbCrLf
s = s & "Cache-Control: no-cache" & vbCrLf
s = s & "Host: www.vbfirums.com" ''''''''''''''''''here
s = s + vbCrLf
Winsock1.SendData s
End Sub
-----------------------------------------
Why need I define "Host" again after I define "RemoteHost" while I "open" this sock?
can I just ignore the 2nd one?
thanks
Re: what's the difference between "host" and" .RemoteHost "
No, you can't ignore it. That second part of your code is a collection of HTTP request headers, and the Host header field identifies the server that you want to connect to. This is important because a lot of webservers are configured to support multiple virtual hosts.
For example, one server could be configured to return pages for www.foo.com and www.bar.com, with both of those host names configured in DNS to return the same IP address. That's how most cheap web hosting companies work; hundreds of domains can be served from the same server, using the same IP address. Because the IP address is shared, the only way that the server knows what pages you really want is based on the hostname that's provided in that header field.
By the way, I'd also get rid of the "Accept-Encoding: gzip , deflate" line there unless your program is really prepared to accept a compressed data stream. My guess is that you're not.
Re: what's the difference between "host" and" .RemoteHost "
Re: what's the difference between "host" and" .RemoteHost "
Using my code you could accept gzip, deflate compressed data.
It would speed up the transfer.
Check out this post.
http://www.vbforums.com/showthread.php?t=396509
idolpx :)