![JAR search and dependency download from the Maven repository](/logo.png)
com.github.mikesafonov.smpp.server.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smpp-server-mock-core Show documentation
Show all versions of smpp-server-mock-core Show documentation
Smpp server to test smpp connection
package com.github.mikesafonov.smpp.server;
import lombok.experimental.UtilityClass;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.UUID;
/**
* @author Mike Safonov
*/
@UtilityClass
public class Utils {
static int checkPortOrGetFree(int port) {
if (port == MockSmppServer.RANDOM_PORT) {
return findRandomOpenPortOnAllLocalInterfaces();
} else {
return port;
}
}
static String randomUuidName() {
return UUID.randomUUID().toString();
}
static synchronized Integer findRandomOpenPortOnAllLocalInterfaces() {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
} catch (IOException e) {
throw new RuntimeException("Unable to find port", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy