Rusty Well-Known Member Licensed User Longtime User Jul 24, 2015 #1 I have an Android app that needs to use TCP/Astreams/Prefix Mode to connect to a server (i.e. 192.168.1.1) and then communicate a bit then disconnect and then connect to another server (i.e. 192.168.1.2). I am having some difficulty getting it to disconnect and also re-connect. Any suggestions are appreciated. I issue a stopservice and then a startservice to re-initialize everything. I think these two events occur too fast. Is there a way to detect service destroy? My TCP code is a service. Thanks, Rusty
I have an Android app that needs to use TCP/Astreams/Prefix Mode to connect to a server (i.e. 192.168.1.1) and then communicate a bit then disconnect and then connect to another server (i.e. 192.168.1.2). I am having some difficulty getting it to disconnect and also re-connect. Any suggestions are appreciated. I issue a stopservice and then a startservice to re-initialize everything. I think these two events occur too fast. Is there a way to detect service destroy? My TCP code is a service. Thanks, Rusty
Erel B4X founder Staff member Licensed User Longtime User Jul 26, 2015 #2 Stopping the service will not disconnect AsyncStreams. You should instead call AsyncStreams.Close and then create the new connection. Upvote 0
Stopping the service will not disconnect AsyncStreams. You should instead call AsyncStreams.Close and then create the new connection.
Rusty Well-Known Member Licensed User Longtime User Jul 26, 2015 #3 Thanks Erel. I have been successful by leaving the service running; closing Astreams; closing the socket; changing the IP address and letting the service re-open the new IP address. Works well...even repeatedly. Once again, thanks for the guidance. Rusty Upvote 0
Thanks Erel. I have been successful by leaving the service running; closing Astreams; closing the socket; changing the IP address and letting the service re-open the new IP address. Works well...even repeatedly. Once again, thanks for the guidance. Rusty