title: Java Linux: java.net.BindException: Address already in use
body: <p>I am using Linux Mint 14 KDE. I've successfully created Java tcp server and client, server IP:port is 10.10.1.10:9900 and my client IP:port 10.10.1.10:9901. When i connect my client for the first time everything is OK. The client connects and sends some data and disconnects. When i try connecting the client with the server right after disconnecting i get the next Exception.</p>
  
  <pre><code>java.net.BindException: Address already in use
  </code></pre>
  
  <p>If i wait more than 1 minute everything is OK. On other forums i read that after closing the socket there is a tcp time_wait that is 60 seconds (1 minute). After changing it to 0 everything worked (If someone want to change it just add this line <strong>net.ipv4.tcp_fin_timeout=0</strong> in <strong>/etc/sysctl.conf</strong> and execute this line in your terminal as root <strong>service networking restart</strong>). The next day i tried to do one more test and i got the same exception. I checked if the time is still 0 (U can check it with writing this in command line <strong>cat /proc/sys/net/ipv4/tcp_fin_timeout</strong> as root) and it was 0. I still had to wait 1 minute before reconnecting the client.</p>
  
  <p>Can someone help me how to configure that way so i don't get this exception. Waiting 1 minute is too much for real-time application. I know i can do this with letting the OS dynamically assign port number that is free, but that is not what my application needs are.</p>