Weak weak to ask two questions,
1, if the Socket is broken, how can I judge ah?
2, with the background to write a timer, every 5 seconds to send a heartbeat packet, the result of old pop XXX does not respond, whether the end ...
Distressed ah, there are heroes help under it?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
1.
try {
socket.sendUrgentData (0xFF);
} Catch (IOException e) {
/ / Received to explain this anomaly socket has closed
}
2 Network operation to open a new thread to do, not on the main thread, it will be very easy to ANR. If this is not the problem, could you put the code and log, facilitate analysis of the problem.
Reply:
First, the program appears relatively time-consuming operation, you must open a new thread, service is not able to handle time-consuming operations,
For the socket to determine if you can look at this blog, in more detail:
http://blog.csdn.net/yudajun/article/details/10062339
Reply:
Upstairs really easy to use, has solved the problem! Tested, the effect is quite good! Thank you
No comments:
Post a Comment