What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Visual Basic Help

Visual Basic Help
Author: Message:
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Visual Basic Help
Ok heres the whole function. This is for a WinSock control. This is the DataArrival function.

Now what I'm trying to do is set up sort of a proxy thing where I set my IE or FireFox to proxy 127.0.0.1:4444 and it connects to my program. Now if a URL with a TLD of .in2 is typed it will search through the database list and find the location of that .in2. For example I type this in IE: www.test.in2. Now my program will see thats its an .in2 so then now it will look up test.in2 in the database list and find the location of the site. Then it sends the information back to the browser to load the correct page. So far it works preaty good but when ever I try and access a site that is the last item on the database list I get that runtime error.

I'm not sure if you will understand what I just typed. I'll be glad to send you my project files because I think that may be more of a help. Any ways the code below is the code thats responsible for checking if its a .in2, looking it up in the list, then sending info back to browser. And it also will allow any normal sites like .com to pass right through.

The code it said it had the error on was:
code:
List1.ListIndex = List1.ListIndex + 1

code:
Private Sub srvIn_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    Dim sckData As String   ' Socket data
    Dim remHost As String   ' What is the remote host ?
    Dim tarSite As String   ' What site is the proxy user requesting ?
    Dim unfSite As String   ' Same as above but unformated!
    Dim websitein2 As String
    Dim tmpb As String
    Dim j As Integer
    Dim s As String
   
        ' Add to log
        AddLog "SrvIn", "Data arrived (" & Index & ")"
   
        ' Get the data
       srvIn(Index).GetData sckData, vbString, bytesTotal
       
        ' Get the targeted site (unformated)
        unfSite = FetchRequestedPage(sckData)
       
        ' Fetch the remote host
        remHost = GetHttpVars(sckData, "Host")
       
        ' Check if a url/host has been fetched so we can confirm that it is http traffic
        If IsEmpty(unfSite) Or IsEmpty(remHost) Then UnloadProxyUser (Index): Exit Sub
       
        ' Fetch the targeted site
        tarSite = StripHost(unfSite)
       
        ' Log the url visited
        'WriteUrlLog (unfSite)
       
         
If InStr(unfSite, ".in2") Then
       
    websitein2 = unfSite
       
        If InStr(websitein2, "www.") Then
            websitein2 = Replace(websitein2, "www.", "")
        End If
        If InStr(websitein2, "http://") Then
          websitein2 = Replace(websitein2, "http://", "")
        End If
        If InStr(websitein2, "/") Then
            websitein2 = Replace(websitein2, "/", "")
        End If

List1.ListIndex = 0
For a = 0 To List1.ListCount - 1
    If InStr(List1, websitein2) Then
        s = ""
        s = s + Mid$(List1, InStrRev(List1, "-") + 2)
        s = Replace(s, "http://", "")
    Else
        List1.ListIndex = List1.ListIndex + 1
    End If
Next a
       
          ' Update http request
        sckData = Replace(sckData, GetDomain(unfSite), "/")
        sckData = Replace(sckData, remHost, s)
        sckData = Replace(sckData, "Proxy-Connection:", "Connection:")
       
        ' Set the data
        ProxyUsers(Index).ProxyUserData = sckData
       
        ' Set remote host
        ProxyUsers(Index).ProxyRequHost = s
       
        ' Init a connection to retrive the data
        MakeProxyConnection (Index)
       
        ' Unload the user
        UnloadProxyUser (Index)
       
GoTo endit
End If
       
       
        ' Update http request
       
        sckData = Replace(sckData, GetDomain(unfSite), "/")
        sckData = Replace(sckData, "Proxy-Connection:", "Connection:")
       
        ' Set the data
        ProxyUsers(Index).ProxyUserData = sckData
       
        ' Set remote host
        ProxyUsers(Index).ProxyRequHost = remHost
        ' Init a connection to retrive the data
        MakeProxyConnection (Index)
       
        ' Unload the user
        UnloadProxyUser (Index)
       
        Exit Sub

endit:
    End Sub
[Image: top.gif]
03-20-2006 01:18 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Visual Basic Help - by DJeX on 03-19-2006 at 11:21 PM
RE: Visual Basic Help - by matty on 03-19-2006 at 11:45 PM
RE: Visual Basic Help - by CookieRevised on 03-20-2006 at 12:04 AM
RE: Visual Basic Help - by DJeX on 03-20-2006 at 01:18 AM
RE: Visual Basic Help - by CookieRevised on 03-20-2006 at 08:31 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On