开发者

Socket Connection Problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜