< prev index next >

test/java/nio/channels/Channels/Basic2.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4607272
  26  * @summary Test Channels methods for interoperability between streams and
  27  *     asynchronous byte channels

  28  */
  29 
  30 import java.net.*;
  31 import java.io.*;
  32 import java.nio.channels.*;
  33 import java.util.Random;
  34 
  35 public class Basic2 {
  36 
  37     static final Random rand = new Random();
  38 
  39     public static void main(String[] args) throws Exception {
  40         // establish loopback connection
  41         AsynchronousServerSocketChannel listener =
  42             AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
  43         int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
  44         InetSocketAddress isa =
  45             new InetSocketAddress(InetAddress.getLocalHost(), port);
  46         AsynchronousSocketChannel ch1 = AsynchronousSocketChannel.open();
  47         ch1.connect(isa).get();




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4607272
  26  * @summary Test Channels methods for interoperability between streams and
  27  *     asynchronous byte channels
  28  * @key randomness
  29  */
  30 
  31 import java.net.*;
  32 import java.io.*;
  33 import java.nio.channels.*;
  34 import java.util.Random;
  35 
  36 public class Basic2 {
  37 
  38     static final Random rand = new Random();
  39 
  40     public static void main(String[] args) throws Exception {
  41         // establish loopback connection
  42         AsynchronousServerSocketChannel listener =
  43             AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
  44         int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
  45         InetSocketAddress isa =
  46             new InetSocketAddress(InetAddress.getLocalHost(), port);
  47         AsynchronousSocketChannel ch1 = AsynchronousSocketChannel.open();
  48         ch1.connect(isa).get();


< prev index next >