As I read it, if the socket number is different than 4 it fails. Why is that?
How is that failing? 0 usually means no error occurred.
The value in _sock is incremented, from 0, each time a connection is made. If the value gets to be 4, that represents the 5th or 4 connections that can be pending. That is a cause for failure.
If you are not closing the client connection correctly, by reading all the data that the server sends, it is possible to run out of sockets. Then, you need to reset to force the connections to be closed.
So, where is your code?