title: Java Socket Permissions - java.security.AccessControlException
body: <p>I am having trouble making a client server to run  in a sandbox, where it is only allowed that the connections between client/server only happen in one specific port.</p>
  
  <p>In my code I only use port number: 23456, and this happens in the server console:</p>
  
  <pre><code>*Exception in thread "main" java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:52267" "accept,resolve")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkAccept(Unknown Source)
      at java.net.ServerSocket.implAccept(Unknown Source)
      at java.net.ServerSocket.accept(Unknown Source)*
  </code></pre>
  
  <hr>
  
  <p>This is what I have in my client sandbox:</p>
  
  <pre><code>grant {
  
      permission java.net.SocketPermission "*:23456", "accept, listen, connect, resolve";
      (..)
      };
  </code></pre>
  
  <p>this is what I have in my server sandbox:</p>
  
  <pre><code>grant {
  
  permission java.net.SocketPermission "*:23456", "accept, listen, connect, resolve";
  (...)
  };
  </code></pre>