-
I don't know if I can explain what I am after very well so here goes:
how do you make multiple winsock controls at run time? as in I think it is called control arrays or something for example you'd have winsock1(0) winsock1(1) winsock1(2) and so on until say about 50 or so that you can have more than one connection sort of thing?
and can someone give me a code to show how to connect and send data with multiple winsocks?
thanx
-
Let me try to help you.. :)
Code:
'/* ================= Server ==================
Public intMax as Integer
Private Sub srvwinsock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
'here i am making every time if someone is connecting
'to your app a new index is creating for the
'winsock control
If Index = 0 Then
intMax = intMax + 1
'load a new windsock control
Load srvwinsock(intMax)
srvwinsock(intMax).LocalPort = 0
srvwinsock(intMax).Accept requestID
End If
End Sub
Private Sub srvwinsock_DataArrival(Index As Integer, ByVal bytesTotal As Long)
On Error Resume Next
With srvwinsock.Item(Index)
' read the data and place it in a string
.GetData strData
End With
End Sub
'/* ============== Client ===================
Private Sub cltwinsock_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
With cltwinsock
' read the data and place it in a string
.GetData strData
End With
End Sub
Private Sub cltwinsock_Close()
call MsgBox("Connection closed!", vbOKOnly, App.Title)
With cltwinsock
.Close
End With
End Sub
/* ==========================================
I have created a example client/server chat app with the
winsock control (uhhhh never finished thou). But if you want it send me a email.. :)
-Kayoca Mortation