Thanks for your answer,
yes first the whole code was in the function, the list and all the other things, now i changed it so i can terminate the thread and clear the list in a shutdown function.
I dont want to open another thread so i ask here, i read that the maximum of sent packets per second is 30. Is this per socket? What is the bottleneck for this limitation? CPU, Networkcard, Bandwidth, OS?