获取连接拒绝localSocketConnection的IO异常

时间:2015-10-27 12:01:12

标签: android sockets android-wifi wlan

我正在尝试使用Android SDK为Creating local socket

提供的API,在Android应用程序的本地到wlan0(WIFI)界面创建一个unix域套接字

以下是我的代码

10-27 17:17:08.465    3212-3212/com.test.sockettest D/exception raised﹕ java.io.IOException: Connection refused
            at android.net.LocalSocketImpl.connectLocal(Native Method)
            at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:258)
            at android.net.LocalSocket.connect(LocalSocket.java:108)
            at com.globaledgesoft.sockettest.MainActivity.onCreate(MainActivity.java:24)
            at android.app.Activity.performCreate(Activity.java:5133)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
            at android.app.ActivityThread.access$600(ActivityThread.java:150)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:5225)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
            at dalvik.system.NativeStart.main(Native Method)

以下是日志异常的堆栈跟踪

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_LOGS" />

任何人都可以帮助我理解为什么我得到这个例外,我实际上已经获得了许可。下面是我的清单权限字符串。

{{1}}

我是Android Socket编程新手,

提前感谢您的帮助

0 个答案:

没有答案