The for each loop where you're processing the close command :
for each (Socket ^client in clientarr)
is actually looping over all 100 elements in the array, most of which are null. That's because for each doesn't know anything about the validity of the values of the array elements, it just sees 100 handles that you've allocated, so then it blows up when you access the RemoteEndPoint property. I found that adding a check for null fixes the code:
if (clientarr[index] == nullptr) continue;
|