Android Question Multiple Connections

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I have a database with multiple rows which contain IP addresses.

What I want to do is connect to each IP address using a socket and keep the connection alive even when the app is closed.

This seems easy enough using a service.

However, the part I need help with is how to make the connection to multiple IP address if I don't know how many there are going to be?

I know how to connect to the IP and send data by using this: http://www.b4x.com/android/forum/threads/asyncstreams-tutorial.7669/#content

However I need to Dim & Initialize the socket but without knowing how many connections there are going to be.

Then I don't know how to use 'AStreams_NewData' for each socket as I want each socket to be unique to each other.

The only way I can think of is limit the number of socket connections the customer can have and dim & Initialize each in my code.

I know having the socket open all the time will flatten the battery etc. but I am going to add a message letting the user know about the battery going flat and data charges when using data on there mobile phone. (leave it up the customer to decide if they want to keep the connection alive, but want to add this in the app)

Anyone know how to do this ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…