I need to create 1000 server sockets using Java. Somewhere between creating 600 and 700 sockets I’m getting this error:
05.04.2012 10:23:57 java.net.SocketException: No buffer space available (maximum connections reached?): listen at sun.nio.ch.ServerSocketChannelImpl.listen(Native Method) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:127) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52) at channelserver.NIOAppServer.initSelector(NIOAppServer.java:40) at channelserver.NIOAppServer.(NIOAppServer.java:27) at channelserver.NIOServer.main(NIOServer.java:433) at channelserver.NIOServer.main(NIOServer.java:438)
After that my computer reboots.
I’ve tried to edit the registry setting MaxUserPort = 65534 and MaxFreeTcbs = 2000, but it didn’t help.
What else can I do?
On http://serverfault.com someone told me that it may be related to JDBC, but I connect to DB only once. I use SQLite.
Any suggestions?
Just in case someone would face this problem too.
Finally it seemed to me that it’s just WinXP’s problem. I’ve tried the same code with more RAM – results were the same. But when I’ve tried it on Win7, everything worked fine even with 1200 sockets.
So, WinXP is just not suitable for such tasks.