java - Limit between successive JVM bind calls to same port -


i have java code sets server on particular port, code run in python uses server, , port closed. i've set after each python run, java loops , repeats process (setting new server, serving, closing).

i notice when python call short (about <10s), next time java tries set port, fail. there rules how long must wait between successively setting same port on java?

ports can finicky type of thing. they're not meant opened , closed time. should leave socket open , handle each connection within, this:

    serversocket listener = new serversocket(9090);     try {         while (true) {             socket socket = listener.accept();             try {                 printwriter out =                     new printwriter(socket.getoutputstream(), true);                 out.println(new date().tostring());             } {                 socket.close();             }         }     }     {         listener.close();     } 

(credit: http://cs.lmu.edu/~ray/notes/javanetexamples/)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -