2
我已經看過關於這個問題的其他答案,但他們大多聲明在綁定套接字之前調用setReuseAddress (true)
。但我正在這樣做,它仍然無法工作,有人可以幫我在這裏嗎?Android,setReuseAddress不起作用
SocketChannel tunnel = SocketChannel.open();
if (!protect(tunnel.socket())){
throw new IllegalStateException("Can not protect tunnel");}
Log.i("TAG", "test");
tunnel.socket().setReuseAddress(true);
tunnel.socket().bind(new InetSocketAddress(localAddress, localPort));
Log.i("TAG", "bind test");
tunnel.connect(new InetSocketAddress(destAddress, destPort));
tunnel.configureBlocking(false);
packet.position(0);
packet.limit(length);
Log.i("TAG", "schreibe: " + tunnel.write(packet));
packet.clear();
哦,好吧,我不知道,謝謝! – Fischa