本来想做个tcp的net穿透,但是端口复用就出问题了。都说setReuseAddress设置为true的话可以实现端口复用,可是
Socket socket1 = new Socket();
Socket socket2 = new Socket();
socket1.setReuseAddress(true);
socket2.setReuseAddress(true);
socket1.bind(new InetSocketAddress("127.0.0.1", 88));
socket2.bind(new InetSocketAddress("127.0.0.1", 88));
这样还是报Address already in use的错误,难道是java版本的问题?
试试不要用new InetSocketAddress("127.0.0.1", 88) 这样的话new了两次了