I have used the Networking example provided by Erel to build a B4J server and a B4A client.
I can successfully create a connection from the android device, send a message to the Server and get a response.
What I want to be able to have is multiple Android Clients but I can't work out how to handle concurrent connections.
I think I need to do something to create multiple streams at this point.
But I don't know how. (Arrays of streams and sockets doesn't work
)
I can handle multiple streams with the same code as the message coming from the client device includes an id that is unique to that device.
Any help would be greatly appreciated. Or just point me at some examples and I'll try and work it out.
I can successfully create a connection from the android device, send a message to the Server and get a response.
What I want to be able to have is multiple Android Clients but I can't work out how to handle concurrent connections.
I think I need to do something to create multiple streams at this point.
B4X:
server.listen
Wait For server_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("New Connection")
If Successful Then
If astream.IsInitialized Then
astream.Close
End If
astream.InitializePrefix(NewSocket.InputStream, True, NewSocket.OutputStream, "astream")
setState(True)
End If
But I don't know how. (Arrays of streams and sockets doesn't work
I can handle multiple streams with the same code as the message coming from the client device includes an id that is unique to that device.
Any help would be greatly appreciated. Or just point me at some examples and I'll try and work it out.
Last edited: