+doc #19429 initial merge of docs-dev and docs

This commit is contained in:
Konrad Malawski 2016-01-13 16:25:24 +01:00
parent be0c8af4c0
commit 5a18d43435
501 changed files with 9876 additions and 3681 deletions

View file

@ -0,0 +1,31 @@
/**
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.util;
import java.net.InetSocketAddress;
import java.io.IOException;
import java.net.ServerSocket;
import java.nio.channels.ServerSocketChannel;
public class SocketUtils {
public static InetSocketAddress temporaryServerAddress(String hostname) {
try {
ServerSocket socket = ServerSocketChannel.open().socket();
socket.bind(new InetSocketAddress(hostname, 0));
InetSocketAddress address = new InetSocketAddress(hostname, socket.getLocalPort());
socket.close();
return address;
}
catch (IOException io) {
throw new RuntimeException(io);
}
}
public static InetSocketAddress temporaryServerAddress() {
return temporaryServerAddress("127.0.0.1");
}
}