/** * TcpClientDemo13 shows typical TCP/IP client programming in Java. It * just reads one line from port 13 of the given host, prints the * line, and quits. * /* Copyright (c) 1999-2002 E. W. Grundke. All rights reserved. * @author E. W. Grundke */ import java.io.*; import java.net.*; public class TcpClientDemo13 { private final static int PORT=13; // the time-of-day port public static void main (String args[]) { if (args.length < 1) { // must have 1+ command-line parameters System.out.println("Usage: java TcpClientDemo13 "); System.out.println("Example: java TcpClientDemo13 borg.cs.dal.ca"); System.out.println("Example: java TcpClientDemo13 129.173.66.61"); System.exit(1); } try { Socket s = new Socket(args[0], PORT); BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream())); String str = input.readLine(); System.out.println (str); } catch (IOException e) {System.out.println(e);} } }