Solved

2 winsocks intro 1 winsock

Posted on 2007-03-28
2
199 Views
Last Modified: 2010-04-30
hello,
I am using two winsock in my code but I would like to have only 1.
its not using the same one at the same time!
how can I do that??

Private Sub Winsock_Connect()
Winsock.SendData Login("user", "pass")
Label3.Caption = "Sending Login..."
End Sub

Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock.GetData data
txtURL1 = GetStringBetween(txtAnswer1, "Location: ", "" & vbNewLine & "Set-Cookie:")
txtCookie = GetStringBetween(txtAnswer1, "Set-Cookie: ", "" & vbNewLine & "Location:")
Label3.Caption = "Login ok..."
Winsock.Close
Winsock2.Connect
End Sub

Private Sub Winsock2_Connect()
Winsock.SendData Login2(txtURL1, txtCookie)
Label3.Caption = "Sending confirmation..."
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock.GetData data

If InStr(txtAnswer2, "loggedin.asp") Then
Label3.Caption = "Logged in!"
End If

If InStr(txtAnswer2, "error.asp") Then
Label3.Caption = "Login incorrect!"
End If
End Sub
0
Comment
Question by:Sabrin
  • 2
2 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18807019
don't see why you need to just use 1. 2 should work better for you.
However

Private Sub Winsock2_Connect()

 ' should it be Winsock2.SendData Login2(txtURL1, txtCookie)
Winsock.SendData Login2(txtURL1, txtCookie)  
Label3.Caption = "Sending confirmation..."
End Sub


Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim data As String

' it should Winsock2.GetData data
Winsock.GetData data

If InStr(txtAnswer2, "loggedin.asp") Then
Label3.Caption = "Logged in!"
End If

If InStr(txtAnswer2, "error.asp") Then
Label3.Caption = "Login incorrect!"
End If
End Sub
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 18807047
if use 1

public SetFirst as boolean
Private Sub Winsock_Connect()
SetFirst = true
Winsock.SendData Login("user", "pass")
Label3.Caption = "Sending Login..."
End Sub

Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock.GetData data
if (SetFirst) then
SetFirst = false
txtURL1 = GetStringBetween(txtAnswer1, "Location: ", "" & vbNewLine & "Set-Cookie:")
txtCookie = GetStringBetween(txtAnswer1, "Set-Cookie: ", "" & vbNewLine & "Location:")
Label3.Caption = "Login ok..."
Winsock.SendData Login2(txtURL1, txtCookie)
Label3.Caption = "Sending confirmation..."
'Winsock.Close
'Winsock2.Connect
else
If InStr(txtAnswer2, "loggedin.asp") Then
Label3.Caption = "Logged in!"
End If

If InStr(txtAnswer2, "error.asp") Then
Label3.Caption = "Login incorrect!"
End If

end if
End Sub
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now