title: java.net.SocketException: No buffer space available (maximum connections reached?)
body: <p>I am looking a solution of the exception <code>java.net.SocketException: No buffer space available (maximum connections reached?)</code> that I am getting in my Logs. </p>
  
  <p>Environment:
  Windows Server 2008 R2
  JDK 7 update 25</p>
  
  <p>Stack Trace:</p>
  
  <blockquote>
    <p>java.net.SocketException: No buffer space available (maximum
    connections reached?): JVM_Bind at 
    java.net.TwoStacksPlainSocketImpl.socketBind(Native Method) at
    java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
    at
    java.net.TwoStacksPlainSocketImpl.bind(TwoStacksPlainSocketImpl.java:101)</p>
  </blockquote>
  
  <p>The solution that I am getting in all the hits-</p>
  
  <pre><code>The solution is to open the registry editor and locate the registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters and add a new entry as shown below:
  
  Value Name: MaxUserPort
  Value Type: DWORD
  Value data: 65534
  </code></pre>
  
  <p>Increasing the number of ephemeral TCP ports in registry, is the right solution? What is the other solution? Is there any other programmatic approach to manage and close the these socket connections?</p>