I close the connection correctly, but the time_wait connections increase. Did I miss something?
TIME_WAITis used by the kernel to ensure that your TCP stream does not reuse a port that can still send packets from a remote location. Typically, time TIME_WAITequals doubles the maximum age of packets on network settings.
, TIME_WAIT, - , . grep TIME_WAIT, , . , , .
, , close(). TIME_WAIT , . . TCP TIME_WAIT .
, ( ), , - . , TIME_WAIT .
, close() first @kannan? , , , "" . , EOF, " " .
, , try ... finally . - :
public void run() {
try {
write(this.client.getInputStream(), new File(
CentralizedLogging.logsDir + File.separator
+ client.getInetAddress().getHostName() + "_"
+ getFormattedDate() + ".log"));
} catch (Exception e) {
try {
e.printStackTrace();
write(new ByteArrayInputStream(e.getMessage().getBytes()),
new File(CentralizedLogging.logsDir + File.separator
+ "centralLoggingError.log"));
} catch (IOException io) {
}
} finally {
this.client.close();
}
}