You need to increase your allowed per-process file handles. You can allow a user to use more filehandles with this:
# Put this in /etc/security/limits.conf
someusername soft nofile 65535
someusername hard nofile 65535
(where someusername is the user that will run your program.)