Android mobile phone socket communication (server and client)

This example shares the socket communication code of Android mobile phone for your reference. The specific contents are as follows

1. Firstly, the IP address and port number of the server should be defined for socket communication;

(1). First look at the server code:

(2). Because the mobile phone is the server, the client does not know the IP and port number at the beginning of the operation, but you can see it after the server runs (Pro: you can test it yourself)

2. Client code

3. Finally, don't forget to add network permissions

<uses-permission android:name="android.permission.INTERNET" />

Source code download: http://xiazai.jb51.net/201608/yuanma/android-socket (jb51.net). rar

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
分享
二维码
< <上一篇
下一篇>>