开发者

Client socket maintaining queue/pooling

开发者 https://www.devze.com 2023-02-25 18:20 出处:网络
I am trying to create a client socket connection, when a new request is created a connection is established & data transfer takes place. Is there any way that once the Connection is created it wil

I am trying to create a client socket connection, when a new request is created a connection is established & data transfer takes place. Is there any way that once the Connection is created it will be open for all time ? If yes then how can create it & also how can I 开发者_JAVA技巧identify what request is sent & got the response for the same request?

Looking forward for your response.


You can create a connection for all time, by not closing it. However the trick is detecting when a connection has failed. e.g. the client/server has restarted.

If you want to match requests to responses you can use a request id, but a much simpler approach is to only send one request at a time per socket, that way the response you get is for the request you just sent. You can use more than one socket in a thread if this is required.

0

精彩评论

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

关注公众号