performance - Reproduce tcp CLOSE_WAIT state with java client/server -
is there easy way reproduce tcp close_wait state java program?
i have legacy java application have problem , i'd able reproduce can test fix.
thanks
a connection in close_wait state when other side has closed connection side hasn't. easy reproduce:
// client.java (will sleep in close_wait) import java.io.*; import java.net.*; public class client { public static void main(string[] args) throws exception { socket socket = new socket(inetaddress.getbyname("localhost"), 12345); inputstream in = socket.getinputstream(); int c; while ((c = in.read()) != -1) { system.out.write(c); } system.out.flush(); // should in close_wait thread.sleep(integer.max_value); } } // server.java (sends data , exits) import java.io.*; import java.net.*; public class server { public static void main(string[] args) throws exception { socket socket = new serversocket(12345).accept(); outputstream out = socket.getoutputstream(); out.write("hello world\n".getbytes()); out.flush(); out.close(); } }
Comments
Post a Comment