diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 04b8fec..4b90c22 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,7 @@ - + @@ -153,11 +159,25 @@ - @@ -170,9 +190,10 @@ + - + @@ -181,7 +202,7 @@ - + @@ -225,24 +246,26 @@ - - - - - - - + + - - + + + + + + + diff --git a/src/xyz/nextn/Client.java b/src/xyz/nextn/Client.java index 9a8b190..943c41b 100644 --- a/src/xyz/nextn/Client.java +++ b/src/xyz/nextn/Client.java @@ -1,4 +1,23 @@ package xyz.nextn; -public class Client { +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.net.Socket; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +public class Client extends Thread +{ + DateFormat fordate = new SimpleDateFormat("yyyy/MM/dd"); + DateFormat fortime = new SimpleDateFormat("hh:mm:ss"); + final DataInputStream dis; + final DataOutputStream dos; + final Socket s; + + public Client(Socket s, DataInputStream dis, DataOutputStream dos) + { + this.s = s; + this.dis = dis; + this.dos = dos; + } } diff --git a/src/xyz/nextn/Server.java b/src/xyz/nextn/Server.java index 60ba70a..4c0a199 100644 --- a/src/xyz/nextn/Server.java +++ b/src/xyz/nextn/Server.java @@ -2,6 +2,7 @@ package xyz.nextn; import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; @@ -36,6 +37,46 @@ public class Server { public EchoClientHandler(Socket socket) { this.clientSocket = socket; } + + public void run() { + try { + out = new PrintWriter(clientSocket.getOutputStream(), true); + } catch (IOException e) { + e.printStackTrace(); + } + try { + in = new BufferedReader( + new InputStreamReader(clientSocket.getInputStream())); + } catch (IOException e) { + e.printStackTrace(); + } + + String inputLine = null; + while (true) { + try { + if (!((inputLine = in.readLine()) != null)) break; + } catch (IOException e) { + e.printStackTrace(); + } + if (".".equals(inputLine)) { + out.println("bye"); + break; + } + out.println(inputLine); + } + + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + out.close(); + try { + clientSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } }