如何设置在Android上端的超时时间?如何设置、时间、Android

由网友(聊天来的快i)分享简介:我想降低TCP存活时间在一个Socket,我十分钟顺序开放2小时的东西。我可以把它使用的存活与socket的(真正的),但我怎么能控制keepalive报文发送之前的时间?I'd like to lower the TCP keepalive time on a Socket I'm opening from 2 h...

我想降低TCP存活时间在一个Socket,我十分钟顺序开放2小时的东西。我可以把它使用的存活与socket的(真正的),但我怎么能控制keepalive报文发送之前的时间?

I'd like to lower the TCP keepalive time on a Socket I'm opening from 2 hours to something on the order of ten minutes. I can make it use keepalive with socket.setKeepAlive(true), but how can I control the time before a keepalive packet is sent?

它看起来像我可以,如果我用的是NDK做到这一点,但我想分发此code作为一个罐子,所以这不是理想的我。

It looks like I could do this if I was using the NDK, but I want to distribute this code as a jar, so that's not ideal for me.

推荐答案

这可能是太明显了一个答案[即它不是针对特定的情况选择],但你当然可以通过发送1扔掉的字节(在两个方向),每10分钟实现自己的存活。

This is probably too obvious an answer [i.e. it's not an option for your specific case] but you can of course implement your own keepalive by sending 1 throw-away byte (in either direction) every 10 minutes.

阅读全文

相关推荐

最新文章