Usually this happens when you dnt close your socket properly. Make sure you have both shutdown
and closesocket
when you want to close the socket (http://msdn.microsoft.com/en-us/library/windows/desktop/ms741394(v=vs.85).aspx) From MSDN - "Note To assure that all data is sent and received on a connection, an application should call shutdown before calling closesocket"
Before you bind
the socket, you can use SO_REUSEADDR
for setsocketopt
which will "Allows the socket to be bound to an address that is already in use"
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms740476(v=vs.85).aspx)
Finally, look at this blog - http://blogs.technet.com/b/yongrhee/archive/2011/12/19/how-to-troubleshoot-a-handle-leak.aspx