开发者

Socket Connection Problem

开发者 https://www.devze.com 2023-04-05 13:39 出处:网络
I am using Socket connection to establish connections in my application. I have a problem when establishing the tunnel with the server: the connection is being closed 开发者_运维问答automatically afte

I am using Socket connection to establish connections in my application. I have a problem when establishing the tunnel with the server: the connection is being closed 开发者_运维问答automatically after 3 minutes for example so when trying again to get data after 3 or 4 minutes, I will have an exception in the inputStream and outputStream. But the thread that opened the connection will not through any kind of exception since I included a try{ ... } catch (Exception ex) { }.

Now the question is, How to keep alive the socket connection to not close at all?


Have you tried Socket.setKeepAlive(true) ?


This issue is disucsse over on BlackBerry support forums. It is important to remember that when using a portable connected wireless device there are many reasons the connection might go down, and having a short timeout may be beneficial in cases where the connection may not be reliable:

  • Fringe areas
  • inside buildings
  • moving
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号