|
-
Jul 18th, 2005, 03:35 AM
#1
Thread Starter
New Member
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
-
Jul 19th, 2005, 03:05 PM
#2
Junior Member
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.
-
May 27th, 2006, 10:34 AM
#3
Thread Starter
New Member
Re: what's the difference between "host" and" .RemoteHost "
-
Jun 14th, 2006, 05:37 AM
#4
New Member
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
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
|