WSAEMFILE

The error code exists so it should be interesting, right?  I wanted to force this error for Apache httpd on Windows (7 in my case), so I thought I’d create sockets in the child until it failed, then free up the last n of those so that the server could basically work but occasionally encounter socket handle limits under controlled load.  I really didn’t expect this:

[Fri Jul 20 10:28:09.269300 2012] [mpm_winnt:crit] [pid 4540:tid 444] (OS 10055)An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.  : error on last socket create request, after creating 1328724

I was able to successfully create 1.3 million AF_INET/SOCK_STREAM sockets before encountering WSAENOBUFS. So much for trivially forcing a real WSAEMFILE error… If I understand a few web resources correctly, there’s no socket handle limit other than limitations on resources associated with the socket.