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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -