Link to home
Start Free TrialLog in
Avatar of Sabrin
Sabrin

asked on

2 winsocks intro 1 winsock

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
Avatar of EDDYKT
EDDYKT
Flag of Canada image

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
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial