How to open a socket in anticipation of an ensuing HttpURLConnection

I'm working on an Android application that requires very quick responses from our server. We communicate using HttpURLConnections. In an attempt to reduce latency, I'd like to "warm up" the connection by opening the socket when the user is actively using the application so that when we do get a request to send data, the connection will already be established (assuming the socket wasn't closed server side due to timeout). I believe that URL.openConnection() does not actually open this socket (despite its name) until data is actually sent. Is this correct? If so, is there a better way to simply open a socket and pass that to another HTTPURLConnection later without sending data and have that socket stay open for the keep-alive time?

以上就是How to open a socket in anticipation of an ensuing HttpURLConnection的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准