Get a free server port for testing with
Switch branches/tags
Nothing to show
Latest commit 236b3d9 Apr 29, 2017 @jonathanstowe update META
Failed to load latest commit information.
.travis.yml No dependencies don't use panda Feb 10, 2016
LICENCE rename LICENCE as en_GB May 30, 2016


Get a free server port for testing with

Build Status


use Test::Util::ServerPort;

my $port = get-unused-port();

# .. start some server with the port


This is a utility to help with the testing of TCP server software.

It exports a single subroutine get-unused-port that will return a port number in the range 1025 - 65535 (or a specified range as an argument,) that is free to be used by a listening socket. It checks by attempting to listen on a random port on the range until it finds one that is not already bound.


Assuming you have a working Rakudo Perl 6 installation you should be able to install this with panda :

# From the source directory

panda install .

# Remote installation

panda install Test::Util::ServerPort

This should work equally well with zef but I may not have tested it.


Suggestions and patches that may make it more useful in your software are welcomed via github at:


This is free software.

Please see the LICENCE file in the distribution for details.

© Jonathan Stowe 2016, 2017