性能优化
This commit is contained in:
@@ -34,7 +34,6 @@ public class TCPConnection {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
// TODO 自动生成的方法存根
|
||||
try {
|
||||
if (din != null)
|
||||
din.close();
|
||||
@@ -70,36 +69,19 @@ public class TCPConnection {
|
||||
public TCPConnection(Tunnel t) throws UnknownHostException, IOException {
|
||||
this(t, t.connectClientSocket());
|
||||
}
|
||||
|
||||
public TCPConnection(Tunnel t, Socket soc) throws IOException {
|
||||
connect = soc;
|
||||
tunnel = t;
|
||||
// connect.setSoTimeout(10000);
|
||||
din = new DataInputStream(new BufferedInputStream(connect.getInputStream(), 65536));
|
||||
dout = new DataOutputStream(new BufferedOutputStream(connect.getOutputStream(), 65536));
|
||||
ThreadTool.makeVThreadIfSupport("FLUSH", () -> {
|
||||
try {
|
||||
while (true) {
|
||||
Thread.sleep(10);
|
||||
if(flush) {
|
||||
synchronized (dout) {
|
||||
dout.flush();
|
||||
|
||||
}
|
||||
flush=false;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private volatile boolean flush = false;
|
||||
|
||||
public void flush() throws IOException {
|
||||
flush = true;
|
||||
public boolean isOpen() {
|
||||
if(connect==null) {
|
||||
return false;
|
||||
}
|
||||
return !connect.isClosed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user