72N/A/*
2362N/A * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
72N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
72N/A *
72N/A * This code is free software; you can redistribute it and/or modify it
72N/A * under the terms of the GNU General Public License version 2 only, as
72N/A * published by the Free Software Foundation.
72N/A *
72N/A * This code is distributed in the hope that it will be useful, but WITHOUT
72N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
72N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
72N/A * version 2 for more details (a copy is included in the LICENSE file that
72N/A * accompanied this code).
72N/A *
72N/A * You should have received a copy of the GNU General Public License version
72N/A * 2 along with this work; if not, write to the Free Software Foundation,
72N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
72N/A */
72N/A
72N/A/* @test
72N/A * @bug 4403255
72N/A * @summary Tests old streams using channels in socket case
72N/A */
72N/A
72N/Aimport java.io.*;
72N/Aimport java.net.*;
72N/Aimport java.nio.*;
72N/Aimport java.nio.channels.*;
72N/Aimport java.util.*;
72N/A
72N/A
72N/Apublic class GetChannel {
72N/A public static void main(String args[]) throws Exception {
72N/A InetAddress sin = null;
72N/A Socket soc = null,soc1 = null;
72N/A InputStream is = null;
72N/A OutputStream os = null;
72N/A ServerSocket srv = null;
72N/A int port = 0;
72N/A int tout = 1000;
72N/A
72N/A sin = InetAddress.getLocalHost();
72N/A srv = new ServerSocket(port);
72N/A port = srv.getLocalPort();
72N/A soc = new Socket(sin, port);
72N/A soc1 = srv.accept();
72N/A
72N/A BufferedReader bin = new BufferedReader(
72N/A new InputStreamReader(soc.getInputStream()));
72N/A BufferedWriter bout = new BufferedWriter(
72N/A new OutputStreamWriter(soc1.getOutputStream()));
72N/A
72N/A bout.write("hello");
72N/A bout.newLine();
72N/A bout.flush();
72N/A
72N/A String reply = bin.readLine();
72N/A if (!reply.equals("hello"))
72N/A throw new RuntimeException("Test failed");
72N/A
72N/A soc.close();
72N/A soc1.close();
72N/A srv.close();
72N/A }
72N/A}
72N/A