0

此代码在甜甜圈 (api 4) 和果冻豆 (api 17) 上运行良好,但在 sock.read(bb);

不抛出异常。我无法弄清楚它有什么问题。

(new Thread(new Runnable() {  @Override public void run() {
    try {


                DatagramChannel sock= DatagramChannel.open();
                sock.connect(new InetSocketAddress("127.0.0.1", 1910));
                ByteBuffer bb = ByteBuffer.allocate(256);
                sock.configureBlocking(false);  
                                pr("SOCKET Read start!!!");
                sock.read(bb);
                pr("SOCKET Read passed!!!");



    } catch (IOException e) {
                pr("SOCKET BAD!!!");
                e.printStackTrace();
    }
}})).start();
4

0 回答 0