How to see why w5100 failed to connect?

Hi, I am fighting an issue where my sockets do not close and then I run out of sockets. I have looked through my serial data and found that every time I lose a socket, the prior connection request failed. How can I find out why that connection failed? There can be thousands of requests between failed sockets, but in some instances that could mean all sockets are gone in less than 48 hours...

Perhaps your code? Perhaps what you are connecting to?