package MV3500Cohort2018JanuaryMarch.homework1;


//package tcpclient;

import java.io.*;
import java.net.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

/**
 * Before, we always used telnet to connect to the server. We
 * are now writing our own program to do the connection.
 * 
 * As you will see, when we run this after we start the server
 * we will see the same string telnet printed, sent by the server.
 * The output at the server will show different socket pairs for
 * each time we ran it.
 * 
 * @author mcgredo
 */
public class MaroonTcpClient {
    
    public static DataInputStream input;
    public static DataOutputStream output;
    

  
    public static void main(String[] args) 
    {
        Scanner userInput = new Scanner(System.in);
        try
        {
           System.out.println("creating socket");
           Socket socket = new Socket("localhost", 2317); 
           
           input = new DataInputStream(socket.getInputStream());
           output = new DataOutputStream(socket.getOutputStream());
           
           
           
           System.out.println("Type position or ID: \n ");
           String request;
           request = userInput.nextLine();
           output.writeUTF(request);
           
           String reply;
           reply = input.readUTF();
           System.out.println(reply);
           
           
        }
        catch(Exception e)
        {
            System.out.println(e);
            System.out.println("Problem with client");
        }

    }
    
}