Android uses websocket protocol to communicate with the server

In a recent project, the server needs to actively push messages to the client. In this case, the general HTTP connection cannot be used. The blogger asked a friend and recommended the websocket protocol to me. I hereby tested it and found that the effect is very good.

Android itself does not have a websocket library, so you need to download it yourself and the download address.

Client code:

The interface layout is written by yourself. It is a very simple two buttons

The following is the server code:

The websocket Library of jetty7 is used

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>