Package org.mockserver.socket
Class PortFactory
java.lang.Object
org.mockserver.socket.PortFactory
- Author:
- jamesdbloom
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic int[]findFreePorts(int count) Find multiple free ports.
-
Constructor Details
-
PortFactory
public PortFactory()
-
-
Method Details
-
findFreePort
public static int findFreePort() -
findFreePorts
public static int[] findFreePorts(int count) Find multiple free ports. Ports are selected from a larger pool of recently-available ports to reduce the chance of collisions. Callers should handleBindExceptionas the returned ports may be claimed by another process before the caller binds them.- Parameters:
count- the number of free ports to find (must be between 1 and 1000 inclusive)- Returns:
- an array of
countdistinct port numbers that were recently free - Throws:
IllegalArgumentException- if count is not between 1 and 1000
-