5503N/A/*
5503N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5503N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5503N/A *
5503N/A * This code is free software; you can redistribute it and/or modify it
5503N/A * under the terms of the GNU General Public License version 2 only, as
5503N/A * published by the Free Software Foundation.
5503N/A *
5503N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5503N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5503N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5503N/A * version 2 for more details (a copy is included in the LICENSE file that
5503N/A * accompanied this code).
5503N/A *
5503N/A * You should have received a copy of the GNU General Public License version
5503N/A * 2 along with this work; if not, write to the Free Software Foundation,
5503N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5503N/A *
5503N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5503N/A * or visit www.oracle.com if you need additional information or have any
5503N/A * questions.
5503N/A */
5503N/A
5503N/Aimport java.io.InputStream;
5503N/Aimport java.io.OutputStream;
5503N/Aimport java.net.InetAddress;
5503N/Aimport java.net.ServerSocket;
5503N/Aimport java.net.Socket;
5503N/A
5503N/A/*
5503N/A * @test
5503N/A * @bug 8003322
5503N/A * @run shell ioTraceTest.sh IoTraceSocketReadWrite
5503N/A */
5503N/Apublic class IoTraceSocketReadWrite extends IoTraceBase {
5503N/A
5503N/A public void test() throws Exception {
5503N/A IoTraceAgent.setListener(this);
5503N/A
5503N/A ServerSocket ss = null;
5503N/A Socket s1 = null, s2 = null;
5503N/A OutputStream os = null;
5503N/A InputStream is = null;
5503N/A
5503N/A try {
5503N/A InetAddress iaddr = InetAddress.getLocalHost();
5503N/A ss = new ServerSocket(0);
5503N/A s1 = new Socket(iaddr, ss.getLocalPort());
5503N/A s2 = ss.accept();
5503N/A
5503N/A os = s1.getOutputStream();
5503N/A is = s2.getInputStream();
5503N/A
5503N/A os.write((byte) 11);
5503N/A is.read();
5503N/A
5503N/A expectSocket(1, 1, s2.getInetAddress(), s2.getPort(), 0);
5503N/A
5503N/A } finally {
5503N/A if (ss != null) {
5503N/A ss.close();
5503N/A }
5503N/A if (s1 != null) {
5503N/A s1.close();
5503N/A }
5503N/A if (s2 != null) {
5503N/A s2.close();
5503N/A }
5503N/A }
5503N/A }
5503N/A
5503N/A public static void main(String... args) throws Exception {
5503N/A IoTraceSocketReadWrite t = new IoTraceSocketReadWrite();
5503N/A t.test();
5503N/A }
5503N/A}