package ru.matevosyan.client;

import java.net.*;
import java.io.*;

public class BotClient {
    public static void main(String[] ar) {
        int serverPort = 19999;
        String address = "127.0.0.1";

        try {
            InetAddress ipAddress = InetAddress.getByName(address);
            System.out.println("Any of you heard of a socket with IP address " + address + " and port " + serverPort + "?");
            Socket socket = new Socket(ipAddress, serverPort);
            System.out.println("Yes! I just got hold of the program.");

            try (
            InputStream sin = socket.getInputStream();
            OutputStream sout = socket.getOutputStream();

            DataInputStream in = new DataInputStream(sin);
            DataOutputStream out = new DataOutputStream(sout);

            BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in))) {
                String line = null;
                System.out.println("Type in something and press enter. Will send it to the server and tell ya what it thinks.");
                System.out.println();

                while (true) {
                    line = keyboard.readLine();
                    System.out.println("Sending this line to the server...");
                    out.writeUTF(line);
                    out.flush();
                    line = in.readUTF();
                    System.out.println("The server was very polite. It sent me this : " + line);
                    System.out.println();
                }
            } catch (IOException ioe) {
            ioe.getMessage();
        }
        } catch (Exception x) {
            x.printStackTrace();
        }
    }
}
@@ -672,24 +672,26 @@
 tStream();%0A%0A
+//
             
@@ -737,16 +737,18 @@
 m(sin);%0A
+//
         
@@ -799,24 +799,204 @@
 eam(sout);%0A%0A
+            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);%0A            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));%0A%0A
             
@@ -1434,24 +1434,26 @@
 erver...%22);%0A
+//
             
@@ -1475,24 +1475,62 @@
 teUTF(line);
+%0A%0A                    out.write(line);
 %0A           
@@ -1547,24 +1547,27 @@
 ut.flush();%0A
+%0A//
             
@@ -1591,24 +1591,66 @@
 .readUTF();%0A
+                    line = in.readLine();%0A
             

add PrintWrite and BufferedReader