Tabnine Logo
SocketUtils.findAvailableUdpPort
Code IndexAdd Tabnine to your IDE (free)

How to use
findAvailableUdpPort
method
in
org.springframework.util.SocketUtils

Best Java code snippets using org.springframework.util.SocketUtils.findAvailableUdpPort (Showing top 16 results out of 315)

origin: spring-projects/spring-framework

/**
 * Find an available UDP port randomly selected from the range
 * [{@code minPort}, {@value #PORT_RANGE_MAX}].
 * @param minPort the minimum port number
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort(int minPort) {
  return findAvailableUdpPort(minPort, PORT_RANGE_MAX);
}
origin: spring-projects/spring-framework

/**
 * Find an available UDP port randomly selected from the range
 * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort() {
  return findAvailableUdpPort(PORT_RANGE_MIN);
}
origin: org.springframework/spring-core

/**
 * Find an available UDP port randomly selected from the range
 * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort() {
  return findAvailableUdpPort(PORT_RANGE_MIN);
}
origin: org.springframework/spring-core

/**
 * Find an available UDP port randomly selected from the range
 * [{@code minPort}, {@value #PORT_RANGE_MAX}].
 * @param minPort the minimum port number
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort(int minPort) {
  return findAvailableUdpPort(minPort, PORT_RANGE_MAX);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPortWithNegativeMinPort() {
  exception.expect(IllegalArgumentException.class);
  SocketUtils.findAvailableUdpPort(-500);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPortWithZeroMinPort() {
  exception.expect(IllegalArgumentException.class);
  SocketUtils.findAvailableUdpPort(0);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPort() {
  int port = SocketUtils.findAvailableUdpPort();
  assertPortInRange(port, PORT_RANGE_MIN, PORT_RANGE_MAX);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPortWithMin() {
  int port = SocketUtils.findAvailableUdpPort(50000);
  assertPortInRange(port, 50000, PORT_RANGE_MAX);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPortInRange() {
  int minPort = 20000;
  int maxPort = minPort + 1000;
  int port = SocketUtils.findAvailableUdpPort(minPort, maxPort);
  assertPortInRange(port, minPort, maxPort);
}
origin: spring-projects/spring-framework

@Test
public void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
  int port = SocketUtils.findAvailableUdpPort();
  DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"));
  try {
    exception.expect(IllegalStateException.class);
    exception.expectMessage(startsWith("Could not find an available UDP port"));
    exception.expectMessage(endsWith("after 1 attempts"));
    // will only look for the exact port
    SocketUtils.findAvailableUdpPort(port, port);
  }
  finally {
    socket.close();
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Find an available UDP port randomly selected from the range
 * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort() {
  return findAvailableUdpPort(PORT_RANGE_MIN);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Find an available UDP port randomly selected from the range
 * [{@code minPort}, {@value #PORT_RANGE_MAX}].
 * @param minPort the minimum port number
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort(int minPort) {
  return findAvailableUdpPort(minPort, PORT_RANGE_MAX);
}
origin: apache/servicemix-bundles

/**
 * Find an available UDP port randomly selected from the range
 * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort() {
  return findAvailableUdpPort(PORT_RANGE_MIN);
}
origin: apache/servicemix-bundles

/**
 * Find an available UDP port randomly selected from the range
 * [{@code minPort}, {@value #PORT_RANGE_MAX}].
 * @param minPort the minimum port number
 * @return an available UDP port number
 * @throws IllegalStateException if no available port could be found
 */
public static int findAvailableUdpPort(int minPort) {
  return findAvailableUdpPort(minPort, PORT_RANGE_MAX);
}
origin: io.github.kjens93.conversations/conversations

private static int findAvailableUDPPort() {
  return SocketUtils.findAvailableUdpPort(minPort, maxPort);
}
origin: usdot-jpo-ode/jpo-ode

@Autowired
public AbstractUdpReceiverPublisher(OdeProperties odeProps, int port, int bufferSize) {
 this.odeProperties = odeProps;
 this.port = port;
 this.bufferSize = bufferSize;
 try {
   socket = new DatagramSocket(this.port);
   logger.info("Created UDP socket bound to port {}", this.port);
 } catch (SocketException e) {
   logger.error("Error creating socket with port " + this.port 
     + " Will use the next availabel port.", e);
   this.port = SocketUtils.findAvailableUdpPort();
   logger.info("Using alternate port {}", this.port);
   try {
    socket = new DatagramSocket(this.port);
    logger.info("Created UDP socket bound to port {}", this.port);
   } catch (SocketException e2) {
    logger.error("Error creating socket with port " + this.port, e);
   }
 }
}
org.springframework.utilSocketUtilsfindAvailableUdpPort

Javadoc

Find an available UDP port randomly selected from the range [ #PORT_RANGE_MIN, #PORT_RANGE_MAX].

Popular methods of SocketUtils

  • findAvailableTcpPort
    Find an available TCP port randomly selected from the range [ minPort, maxPort].
  • findAvailableTcpPorts
    Find the requested number of available TCP ports, each randomly selected from the range [ minPort, m
  • findAvailableUdpPorts
    Find the requested number of available UDP ports, each randomly selected from the range [ minPort, m
  • <init>
    Although SocketUtils consists solely of static utility methods, this constructor is intentionally pu

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now