Socket connections limit

I cann’t create more than ~40 socket connection. If there are for instance 35 connections everything works fine, but with 40 all tcpip requests get blocked.
I suspect it’s something with configuring npm-tcpip.so, but I don’t know what to do with it. What I found in Utils Reference was something like that:
io-net -ptcpip threads=128
but after this command all connect() calls in my program fail.