Solved

2 winsocks intro 1 winsock

Posted on 2007-03-28
2
201 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 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

10 Experts available now in Live!

Get 1:1 Help Now