| /*========================================================================= |
| * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved. |
| * This product is protected by U.S. and international copyright |
| * and intellectual property laws. Pivotal products are covered by |
| * one or more patents listed at http://www.pivotal.io/patents. |
| *========================================================================= |
| */ |
| import java.io.*; |
| import java.net.*; |
| |
| public class NetworkHoggerClient { |
| public static void main(String[] args) throws IOException { |
| |
| Socket kkSocket = null; |
| PrintWriter out = null; |
| BufferedReader in = null; |
| |
| try { |
| kkSocket = new Socket(args[0], 4444); |
| out = new PrintWriter(kkSocket.getOutputStream(), true); |
| in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); |
| } catch (UnknownHostException e) { |
| System.err.println("Don't know about host: taranis."); |
| System.exit(1); |
| } catch (IOException e) { |
| System.err.println("Couldn't get I/O for the connection to: taranis."); |
| System.exit(1); |
| } |
| |
| String fromServer; |
| |
| while ((fromServer = in.readLine()) != null) { |
| // System.out.println("Server: " + fromServer); |
| if (fromServer.equals("Bye.")) |
| break; |
| |
| out.println(fromServer); |
| } |
| |
| out.close(); |
| in.close(); |
| kkSocket.close(); |
| } |
| } |