< prev index next >

test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2017, 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. --- 1,7 ---- /* ! * Copyright (c) 2003, 2018, 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.
*** 42,51 **** --- 42,53 ---- import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.Random; + import jdk.test.lib.Utils; + public class EchoTest { private static int failures = 0; private static String ECHO_SERVICE = "EchoService";
*** 78,88 **** ByteBuffer bb2 = ByteBuffer.allocate(size+100); sc.configureBlocking(false); Selector sel = sc.provider().openSelector(); SelectionKey sk = sc.register(sel, SelectionKey.OP_READ); int nread = 0; ! long to = 5000; while (nread < size) { long st = System.currentTimeMillis(); sel.select(to); if (sk.isReadable()) { int n = sc.read(bb2); --- 80,90 ---- ByteBuffer bb2 = ByteBuffer.allocate(size+100); sc.configureBlocking(false); Selector sel = sc.provider().openSelector(); SelectionKey sk = sc.register(sel, SelectionKey.OP_READ); int nread = 0; ! long to = Utils.adjustTimeout(5000); while (nread < size) { long st = System.currentTimeMillis(); sel.select(to); if (sk.isReadable()) { int n = sc.read(bb2);
*** 142,152 **** dc.write(bb); // and receive the echo byte b[] = new byte[msg.length() + 100]; DatagramPacket pkt2 = new DatagramPacket(b, b.length); ! dc.socket().setSoTimeout(5000); dc.socket().receive(pkt2); if (pkt2.getLength() != msg.length()) { throw new RuntimeException("Received packet of incorrect length"); } --- 144,154 ---- dc.write(bb); // and receive the echo byte b[] = new byte[msg.length() + 100]; DatagramPacket pkt2 = new DatagramPacket(b, b.length); ! dc.socket().setSoTimeout((int)Utils.adjustTimeout(5000)); dc.socket().receive(pkt2); if (pkt2.getLength() != msg.length()) { throw new RuntimeException("Received packet of incorrect length"); }
< prev index next >