test/java/nio/channels/Selector/Connect.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -25,29 +25,33 @@
* @bug 4511624
* @summary Test Making lots of Selectors
* @library ..
*/
-import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
-import java.util.*;
import java.nio.channels.spi.SelectorProvider;
+import java.util.*;
public class Connect {
static int success = 0;
static int LIMIT = 100;
public static void main(String[] args) throws Exception {
- scaleTest();
+ try (TestUtil.DayTimeServer daytimeServer =
+ TestUtil.DayTimeServer.startNewServer(50)) {
+ scaleTest(daytimeServer);
+ }
}
- public static void scaleTest() throws Exception {
- InetAddress myAddress=InetAddress.getByName(TestUtil.HOST);
- InetSocketAddress isa = new InetSocketAddress(myAddress,13);
+ static void scaleTest(TestUtil.DayTimeServer daytimeServer)
+ throws Exception {
+ InetAddress myAddress = daytimeServer.getAddress();
+ InetSocketAddress isa =
+ new InetSocketAddress(myAddress, daytimeServer.getPort());
for (int j=0; j<LIMIT; j++) {
SocketChannel sc = SocketChannel.open();
sc.configureBlocking(false);
boolean connected = sc.connect(isa);