If the DoS has been successful probably hasn't sense to continue sending DoS tries until reach the 40 times. I mean, if the DoS has been successful probably you want to disconnect() and return here.