Option Explicit
Private col(1 To 5) As Collection
Private strData(1 To 4) As String
Private BufferData(1 To 4) As String
Private Sub Form_Load()
Dim i As Integer, x As Integer
For i = 1 To 5
lvwItems.ListItems.Add , , "Item in Listview: " & i 'several items in the listview
'add strings to the Collections (just an example)
Set col(i) = New Collection
For x = 1 To 50
col(i).Add "string to send to the server"
Next x
Next i
End Sub
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 4 '4 connections to the server
Sockets(i).Close
Sockets(i).Connect "someserver.com", 80
Next i
End Sub
Private Sub Sockets_Connect(Index As Integer)
Call DownloadNextPart(Index) 'start downloading when connected to the server
End Sub
'I'm not sure how to make this work properly
'????
Private Sub DownloadNextPart(Index As Integer)
Dim i As Long
With lvwItems
For i = 1 To .ListItems.Count 'loop through listview items
If Sockets(Index).State = sckConnected Then
'send next string in collection
'if there are no more strings to be sent from a collection then
'start sending strings from the next collection ????
Sockets(Index).SendData col(.ListItems(i).Tag).Item(???????) & vbCrLf
Exit Sub
End If
Next i
End With
End Sub
Private Sub Sockets_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Sockets(Index).GetData strData(Index), vbString 'get data
BufferData(Index) = BufferData(Index) & strData(Index) 'buffer data
If InStr(1, BufferData(Index), "...") Then ' all data has been received
'do something with it
BufferData(Index) = vbNullString 'clear buffer
End If
'if this is the returned data from the last string
'in the collection, then remove Listview item ?????
Call DownloadNextPart(Index) 'download next part
End Sub