套接字错误:D / AndroidRuntime:关闭VM

时间:2013-12-11 05:57:27

标签: android sockets

我的源代码:

tvOut.setText("Connect...");
Log.d("my", "Connect...");
try {
    InetAddress serverAddr = InetAddress.getByName("192.168.1.121");
    Log.d("my", "InetAddress serverAddr...");
    socket = new Socket(serverAddr, 3426);
    Log.d("my", "socket = new Socket...");
...

logcat的:

12-11 00:16:36.605:D / my(1247):连接......

12-11 00:16:36.675:D / my(1247):InetAddress serverAddr ...

12-11 00:16:36.715:D / AndroidRuntime(1247):关闭虚拟机

哪里有错误?

1 个答案:

答案 0 :(得分:0)

使用AsyncTask进行网络连接,并在AndroidManifest.xml中注意Internet权限