Use magic number for closed sockets instead of MAX_SOCK_NUM.

Also, pile of debugging