PDA

Click to See Complete Forum and Search --> : Winsock to Check Webpage


ShadowWal
Aug 9th, 2000, 03:01 AM
greetings, i am having problems using the winsock to download a webpage. i have it working up to the point of getting the page to download. but some of the time it returns a 404 or DNS on a page that does existe and works. im new to using winsock so im not fully sure how to fix this
thanks for any help

code:
listview goes through list of urls, sending them to url_doit2

Sub url_doit2(urlz2 As String)
On Error GoTo errorhand
Dim a
timer2_stat = ""
a = Split(urlz2, "/", 4) ' urlz2 = the first part of url
fList = urlz2
Text1.Text = a(2)
Winsock1.RemoteHost = a(2)
Winsock1.RemotePort = 80
Winsock1.Connect
Timer2.Enabled = True ' used as timeout
While Winsock1.State <> 8
DoEvents
If Winsock1.State = 9 Then Timer2.Enabled = False: Exit Sub
If timer2_stat = "timeout" Then Timer2.Enabled = False: Exit Sub
Wend
Timer2.Enabled = False
timer2_stat = ""
Exit Sub
errorhand:
Select Case (Err.Number)
Case 40006
Winsock1.Close
Case Else
End Select


winsock1.connect:
Dim strCommand As String
Dim strWebPage As String
' flist is the full url
strCommand = "GET " + fList + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + vbCrLf
Winsock1.SendData strCommand