/*
	A basic Java class stub for a Win32 Console Application.
 */
import java.lang.*;     //pld
import java.net.*;      //pld
import java.io.*;
//import java.io.Externalizable;

public class stalkc {

	public stalkc () {
	}

    // The following is useful if you run this from a dynamic console.
    // But don't do that.
    static public void winwait() {
        byte ch[] = new byte[1];
        try {
            System.in.read(ch);
        } catch (IOException ioe) {
            return;
        }
    }

    static public BufferedReader bin;
    static public int destport = 5432;
    
    //============================================================
	//============================================================
    
    static public void main(String args[]) {
	bin = new BufferedReader(new InputStreamReader(System.in));
	    String desthost = args[0]; //"ulam.math.luc.edu";
	    //String desthost = "ulam.math.luc.edu";
	
	    InetAddress dest;
        System.err.print("Looking up address of " + desthost + "...");
	    try {
	        dest = InetAddress.getByName(desthost);
	    }
	    catch (UnknownHostException uhe) {
	        System.err.println("unknown host: " + desthost);
	        return;
	    }
	    System.err.println(" got it!");
	    
	    Socket s;
	    try {
		s = new Socket(dest, destport);
	    }
	    catch(IOException ioe) {
		System.err.println("no socket available");
	 	return;
	    }

	    OutputStream sout;

	    try {
	        sout = s.getOutputStream();
	    } 
	    catch (IOException ioe) {
	        System.err.println("no socket available");
	        return;
	    }
	    
	    //============================================================
	    
	    while (true) {
		String buf;
		try {
	            buf = bin.readLine();
	        }
	        catch (IOException ioe) {
	            System.err.println("readLine() failed");
	            return;
	        }

		buf = buf.concat("\n");

		byte[] bbuf = buf.getBytes();

	        try {
	            sout.write(bbuf);
	        }
	        catch (IOException ioe) {
	            System.err.println("write() failed");
	            return;
	        }

	    } // while
        //winwait();
    }
}

