Is there a way to destroy everything attached to a socket?

And yes, I called the function before changing the index, i fixed it now. Thanks for taking the time to help me!