I have a server socket that listen for connection from more of 100 devices.
When a device connect to the server, it starts to send a data packet every 10 seconds.
If I call "CloseExistingConnection" in the code below, for each data packet the device need to reconnect and all becomes slower.
I see that not calling "CloseExistingConnection" all works better. When a device stops to send data, after a timeout the event "Astream_Terminated" is called.
Is it safe to work like this ?
Is there a limit on the number of connections that can be kept alive in the same moment ?
Where is declared the timeout ? I would like to keep it at 30 second sor so.
When a device connect to the server, it starts to send a data packet every 10 seconds.
If I call "CloseExistingConnection" in the code below, for each data packet the device need to reconnect and all becomes slower.
I see that not calling "CloseExistingConnection" all works better. When a device stops to send data, after a timeout the event "Astream_Terminated" is called.
Is it safe to work like this ?
Is there a limit on the number of connections that can be kept alive in the same moment ?
Where is declared the timeout ? I would like to keep it at 30 second sor so.
B4X:
Private Sub ListenForBls1Connections
Do While working
Bls1ServerSocket.Listen
Wait For Server_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("new connection")
If Successful Then
'CloseExistingConnection
Bls1client = NewSocket
astream.Initialize(Bls1client.InputStream,Bls1client.OutputStream,"astream")
End If
Loop
End Sub
Last edited: