@@ -0,0 +1,1935 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage chatserver;%0A%0Aimport java.io.*;%0Aimport java.net.ServerSocket;%0Aimport java.net.Socket;%0A%0A/**%0A *%0A * @author henri%0A */%0Apublic class Server %7B%0A    private ServerSocket listener;%0A    private Socket socket;%0A    private DataOutputStream output;%0A    private DataInputStream input;%0A    %0A    public void startServer() throws IOException%7B%0A        try%7B%0A            listener = new ServerSocket(6789,10);%0A            while(true)%7B%0A                try%7B%0A                    waitForConnection();%0A                    setupStream();%0A                %7D%0A                catch(EOFException eofException)%7B%0A                    System.out.println(%22Server ended connection.%22);%0A                %7D%0A                finally%7B%0A                    try%7B%0A                        socket.close();%0A                        input.close();%0A                        output.close();%0A                        System.out.println(%22Socket successfully closed!%22);%0A                    %7Dcatch(IOException ioException)%7B%0A                        System.out.println(%22Error, socket did not close correctly!%22);%0A                    %7D%0A                %7D%0A            %7D%0A        %7Dcatch(IOException ioException)%7B%0A            ioException.printStackTrace();%0A        %7D%0A        finally%7B%0A            listener.close();%0A        %7D%0A    %0A    %7D%0A%0A    private void waitForConnection() throws IOException %7B%0A        socket = listener.accept();%0A        System.out.println(%22Host %22 + socket.getInetAddress().toString() + %22 has connected to the sever.%22);%0A        %0A    %7D%0A%0A    private void setupStream() throws IOException %7B%0A        input = new DataInputStream(socket.getInputStream());%0A        output = new DataOutputStream(socket.getOutputStream());%0A        output.flush();%0A        System.out.println(%22Streams are setup.%22);%0A    %7D%0A%7D%0A

Create ChatServer.java