@@ -0,0 +1,3100 @@
+%0A/***********%0AAuthor: Christian Miller%0AClass: CIS4443%0AProgram Requirements: Create a Java program similar to the Java TCP Client program on the G drive.%0AYour program should accept a single properly formed URL (without the protocol%0Aspecifier, examples: www.sbuniv.edu, 10.0.65.10/~jcain,%0A10.0.65.10/~jcain/index.html).  Your program should then create a HTTP 1.1 GET%0Astatement appropriate for that URL and transmit it to the server specified in%0Athe URL.  Your program should then print to standard output everything it%0Areceives back from the server.  Your program should not expect any input other%0Athan that single URL and should automatically end on its own after it has%0Aprinted everything it received from the server for a single URL.%0A%0ANote: You are printing the raw responses, both HTTP and HTML, from the server%0Aand are NOT rendering a web page like a web browser would do.%0A***********/%0A%0A/**  The java.net package contains the basics needed for network operations. */%0Aimport java.net.*;%0A/** The java.io package contains the basics needed for IO operations. */%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class TCPClient%7B%0Apublic static void main(String argv%5B%5D) throws Exception %7B%0A    String modifiedSentence;%0A    /** Define a host server */%0A    System.out.println(%22Please enter an address: %22);%0A    Scanner scan = new Scanner(System.in);%0A    String userInput = scan.nextLine();%0A    URL host =  new URL(%22http:/%22 + %22/%22 + userInput + %22/%22);%0A    /** Define a port */%0A    int port = 80;%0A    StringBuffer instr = new StringBuffer();%0A    String TimeStamp;%0A    System.out.println(%22SocketClient initialized%22);%0A        try %7B%0A            /**Establish a socket connetion */%0A            Socket connection = new Socket(host.getHost(), port);%0A            /** Instantiate a DataOutputStream object */%0A            DataOutputStream outToServer = new DataOutputStream(connection.getOutputStream());%0A            /** Instantiate a BufferedReader object for reading incoming socket streams. */%0A            BufferedReader inFromServer = new BufferedReader(new InputStreamReader(connection.getInputStream()));%0A                        /** Creates an HTTP 1.1 GET statement for the URL input and transmit to the specified server. */%0A                        String getRequest =  %22GET %22 + host.getPath() + %22 HTTP/1.1%5CnHost: %22 + host.getHost() + %22%5CnConnection: close%5Cn%5Cn%22;%0A            outToServer.writeBytes(getRequest);%0A            modifiedSentence = inFromServer.readLine();%0A            System.out.println(%22FROM SERVER:%22 + modifiedSentence);%0A            String fromServer;%0A            do%7B%0A                            fromServer = inFromServer.readLine();%0A                if(fromServer != null)%7B%0A                                System.out.println(fromServer);%0A                                %7D%0A            %7D while(fromServer != null);%0A            /** Close the socket connection. */%0A            connection.close();%0A        %7D//try%0A%0A    catch (IOException f) %7B%0A      System.out.println(%22IOException: %22 + f);%0A    %7D//catch%0A    catch (Exception g) %7B%0A      System.out.println(%22Exception: %22 + g);%0A    %7D//catch%0A  %7D//main%0A%7D//TCPClient%0A

Create TCPClient.java