Hi,
I would like create a multi-socket application. At the begin, i use only 1 socket but i've some problem because the client ask too quickly different information and my app don't send data correctly. The best way is to create a multisocket application. I can't use Astreams because i can't follow the number of the socket.
Actually, i use this code :
I would like know what's the socket number when it receive some data via the sub Socket1_Connected : with the method sender maybe ?
Imagine a grid with 255 sockets and the state; if you've got ideas to manage correctly some sockets, please reply :sign0163:
I would like create a multi-socket application. At the begin, i use only 1 socket but i've some problem because the client ask too quickly different information and my app don't send data correctly. The best way is to create a multisocket application. I can't use Astreams because i can't follow the number of the socket.
Actually, i use this code :
B4X:
Sub Process_Globals
Dim ServerSocket1 As ServerSocket
Dim Socket1(255) As Socket
Dim nbSocket As Int
Dim ServerPort As Int: ServerPort = 3113
End Sub
Sub ServerSocket1_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful = False Then
Log("Socket not succefull")
Socket1(nbSocket).Close
Return
Else
nbSocket = nbSocket + 1
Log("New socket")
Socket1(nbSocket) = NewSocket
ServerSocket1.Listen
End If
End Sub
Sub Socket1_Connected (Successful As Boolean)
Dim InputStream1 As InputStream
Dim OutputStream1 As OutputStream
Dim StrGet As String
InputStream1 = Socket1(nbSocket).InputStream
If InputStream1.BytesAvailable > 0 Then
Dim buffer() As Byte
StrGet = InputStream1.ReadBytes(buffer, 0, 10)
Log(Str) '(don't make effect for the moment)
End if
End Sub
I would like know what's the socket number when it receive some data via the sub Socket1_Connected : with the method sender maybe ?
Imagine a grid with 255 sockets and the state; if you've got ideas to manage correctly some sockets, please reply :sign0163: