@@ -0,0 +1,1521 @@
+package pl.edu.elka.raj;%0A%0Aimport pl.edu.elka.models.Message;%0Aimport pl.edu.elka.models.Node;%0Aimport pl.edu.elka.util.Log;%0A%0Aimport java.io.*;%0Aimport java.net.InetSocketAddress;%0Aimport java.net.Socket;%0A%0A/**%0A * Created by carol on 20/04/2016.%0A */%0Apublic class TCPClient implements Runnable %7B%0A%0A    private String address;%0A    private int port;%0A    private Socket clientSocket;%0A    private Node server;%0A%0A    public TCPClient(String server) %7B%0A        String%5B%5D serverArray = server.split(%22:%22);%0A        address = serverArray%5B0%5D;%0A        port = Integer.parseInt(serverArray%5B1%5D);%0A%0A    %7D%0A%0A    public Node getServer() %7B%0A        return server;%0A    %7D%0A%0A    public void setServer(Node server) %7B%0A        this.server = server;%0A    %7D%0A%0A    public void run() %7B%0A        try %7B%0A            clientSocket = new Socket();%0A            clientSocket.connect(new InetSocketAddress(address, port), 1000);%0A            server = new Node(null, clientSocket, true);%0A            BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));%0A            Message messageSent = new Message(Message.Type.HANDSHAKE, Main.pid, null, null);%0A            server.write(messageSent);%0A            while (!clientSocket.isClosed()) %7B%0A                NetworkController.processMessage(server, inFromServer.readLine());%0A            %7D%0A        %7D catch (Exception e) %7B%0A            Log.LogError(Log.SUBTYPE.CLIENTSOCKET, %22Message: %22 + e.getMessage());%0A        %7D finally %7B%0A            NetworkController.restartClient();%0A        %7D%0A    %7D%0A%7D%0A

Create TCPClient.java