title: Python on Snow Leopard, how to open >255 sockets?
body: <p>Consider this code:</p>
  
  <pre><code>import socket
  store = []
  scount = 0
  while True:
      scount+=1
      print "Creating socket %d" % (scount)
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      store.append(s)
  </code></pre>
  
  <p>Gives the following result:</p>
  
  <pre><code>Creating socket 1
  Creating socket 2
  ...
  Creating socket 253
  Creating socket 254
  Traceback (most recent call last):
    File "test_sockets.py", line 9, in &lt;module&gt;
    File     "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/socket.py", line 159, in __init__
  socket.error: (24, 'Too many open files')
  </code></pre>
  
  <p>Checking sysctl for the allowed number of open files gives:</p>
  
  <pre><code>$ sysctl -A |grep maxfiles
  kern.maxfiles = 12288
  kern.maxfilesperproc = 10240
  kern.maxfiles: 12288
  kern.maxfilesperproc: 10240
  </code></pre>
  
  <p>Which is way more than the 253 sockets I could successfully open...</p>
  
  <p>Could someone please help me in getting this number up to over 500? I am trying to simulate a peer to peer network using real sockets (requirement), with only 50 simulated nodes and 5 outgoing and 5 incoming connections each, would give the number of 500 needed sockets.</p>
  
  <p>By the way, running this same code under Linux gives me about 1020 sockets, which is more the way I like it.</p>