In fact I just checked and that is done by Test::TCP. So, please do not duplicate code.