mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
9bb3d6b972
git-subtree-dir: sgx-jvm/avian git-subtree-mainline:f978eab8d1
git-subtree-split:09e4fe60d0
34 lines
918 B
Java
34 lines
918 B
Java
import java.net.SocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.nio.channels.SocketChannel;
|
|
import java.io.IOException;
|
|
|
|
public class Sockets {
|
|
private static void expect(boolean v) {
|
|
if (! v) throw new RuntimeException();
|
|
}
|
|
|
|
public static void testFailedBind() throws Exception {
|
|
final String Hostname = "localhost";
|
|
final int Port = 22046; // hopefully this port is unused
|
|
final SocketAddress Address = new InetSocketAddress(Hostname, Port);
|
|
final byte[] Message = "hello, world!".getBytes();
|
|
|
|
SocketChannel out = SocketChannel.open();
|
|
try {
|
|
try {
|
|
out.connect(Address);
|
|
expect(false);
|
|
} catch(IOException e) {
|
|
// We're good. This previously triggered a vm assert, rather than an exception
|
|
}
|
|
} finally {
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
testFailedBind();
|
|
}
|
|
}
|