0

当我试图写一个文件时,SocketException 正在抛出。

private void openSocket() {
    try{
    multicastSocket = new MulticastSocket(port);
    multicastSocket.setTimeToLive(2);
    multicastSocket.setReuseAddress(true);
    multicastSocket.setNetworkInterface(networkInterface);
    multicastSocket.joinGroup(groupAddress);
    System.out.println("----------------Port Opened----------------");
    }catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), "openSocket!!"+e, Toast.LENGTH_SHORT).show();
    }
}

日志如下:

09-13 13:30:46.335: W/System.err(23180): java.net.SocketException: No such device
09-13 13:30:46.335: W/System.err(23180):    at org.apache.harmony.luni.platform.OSNetworkSystem.setSocketOption(Native Method)
09-13 13:30:46.335: W/System.err(23180):    at dalvik.system.BlockGuard$WrappedNetworkSystem.setSocketOption(BlockGuard.java:382)
09-13 13:30:46.335: W/System.err(23180):    at org.apache.harmony.luni.net.PlainDatagramSocketImpl.setOption(PlainDatagramSocketImpl.java:198)
09-13 13:30:46.335: W/System.err(23180):    at org.apache.harmony.luni.net.PlainDatagramSocketImpl.join(PlainDatagramSocketImpl.java:137)
09-13 13:30:46.335: W/System.err(23180):    at java.net.MulticastSocket.joinGroup(MulticastSocket.java:190)
09-13 13:30:46.335: W/System.err(23180):    at com.hp.loki.Settings.openSocket(Settings.java:386)
09-13 13:30:46.343: W/System.err(23180):    at com.hp.loki.Settings.access$4(Settings.java:380)
09-13 13:30:46.343: W/System.err(23180):    at com.hp.loki.Settings$2.onClick(Settings.java:183)
09-13 13:30:46.343: W/System.err(23180):    at android.view.View.performClick(View.java:2731)
09-13 13:30:46.343: W/System.err(23180):    at android.view.View$PerformClick.run(View.java:9387)
09-13 13:30:46.343: W/System.err(23180):    at android.os.Handler.handleCallback(Handler.java:587)
09-13 13:30:46.343: W/System.err(23180):    at android.os.Handler.dispatchMessage(Handler.java:92)
09-13 13:30:46.343: W/System.err(23180):    at android.os.Looper.loop(Looper.java:130)
09-13 13:30:46.343: W/System.err(23180):    at android.app.ActivityThread.main(ActivityThread.java:3694)
09-13 13:30:46.351: W/System.err(23180):    at java.lang.reflect.Method.invokeNative(Native Method)
09-13 13:30:46.351: W/System.err(23180):    at java.lang.reflect.Method.invoke(Method.java:507)
09-13 13:30:46.351: W/System.err(23180):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-13 13:30:46.351: W/System.err(23180):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-13 13:30:46.351: W/System.err(23180):    at dalvik.system.NativeStart.main(Native Method)
4

0 回答 0