Networking: How to catch 'java.net.exception: Broken pipe'

jo1234

Active Member
Licensed User
Longtime User
Hi,

my program establishes a connection to my PC using the Socket on the phone and AStreams. Works well and I can exchange data btw phone and PC.

Problem is: How do I detect when the connection gets interrupted and I need to reestablish the connection?

When I switch off the Wifi I get the messages "java.net.exception: Broken pipe" or ": Connection reset by peer", which are show on the screen.

How can I intercept that message and respond to it?

thanks a lot,
Johannes
 

kickaha

Well-Known Member
Licensed User
Longtime User
AsyncStreams includes an error event where you can catch and respond to any error. The example from Erels thread is given below:

B4X:
Sub AStreams_Error
    ToastMessageShow(LastException.Message, True)
End Sub
 
Upvote 0
Top