Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

2 winsocks intro 1 winsock

Posted on 2007-03-28
2
Medium Priority
?
206 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 2000 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

Technology Partners: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

618 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