Solved

2 winsocks intro 1 winsock

Posted on 2007-03-28
2
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
Access 2013 combo box not working 3 60
How to measure sizes and angles in scanned images ? 3 89
Can we place a tooltip on the actual vb6 form 5 52
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

726 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