diff --git a/Übung/BudaServerClientStuff/.idea/.gitignore b/Übung/BudaServerClientStuff/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/Übung/BudaServerClientStuff/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/Übung/BudaServerClientStuff/.idea/misc.xml b/Übung/BudaServerClientStuff/.idea/misc.xml deleted file mode 100644 index e0844bc..0000000 --- a/Übung/BudaServerClientStuff/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Übung/BudaServerClientStuff/.idea/modules.xml b/Übung/BudaServerClientStuff/.idea/modules.xml deleted file mode 100644 index 470b584..0000000 --- a/Übung/BudaServerClientStuff/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Übung/BudaServerClientStuff/BudaServerClientStuff.iml b/Übung/BudaServerClientStuff/BudaServerClientStuff.iml deleted file mode 100644 index c90834f..0000000 --- a/Übung/BudaServerClientStuff/BudaServerClientStuff.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Übung/BudaServerClientStuff/src/BudaClient.java b/Übung/BudaServerClientStuff/src/BudaClient.java deleted file mode 100644 index 0c74c5b..0000000 --- a/Übung/BudaServerClientStuff/src/BudaClient.java +++ /dev/null @@ -1,29 +0,0 @@ - -import java.io.*; -import java.net.Socket; - -public class BudaClient { - public static void main(String[] args) { - Socket sock = null; - try { - sock = new Socket("localhost", 8090); - OutputStream out= sock.getOutputStream(); - BufferedReader conin = new BufferedReader(new InputStreamReader(System.in)); - String line = ""; - while (true) { - line = conin.readLine(); - out.write(line.getBytes()); - if (line.equalsIgnoreCase("Quitx")) { - break; - } - //line.startsWith() //todo: automatically handle name lengths - //TODO: Implement inputStream in. - } - - - } catch (IOException e) { - e.printStackTrace(); - } - } - -} diff --git a/Übung/BudaServerClientStuff/src/BudaClientThread.java b/Übung/BudaServerClientStuff/src/BudaClientThread.java deleted file mode 100644 index 9bd8066..0000000 --- a/Übung/BudaServerClientStuff/src/BudaClientThread.java +++ /dev/null @@ -1,73 +0,0 @@ - - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; - -public class BudaClientThread implements Runnable { - int number; - Socket socket; - String name; - - - public BudaClientThread(int number, Socket socket) { - this.number = number; - this.socket = socket; - name = ""; - } - - public void run() { - System.out.println("Connection " + number + " established."); - try { - InputStream in = socket.getInputStream(); - OutputStream out = socket.getOutputStream(); - byte[] command; - String comString; - while (true) { - command = new byte[5]; - System.out.println("Waiting to receive a line"); - in.read(command); - System.out.println("Got a line!"); - comString = new String(command); - System.out.println("Client number " + number + " sent this message: " + comString); - if (comString.equalsIgnoreCase("Quitx")) { - BudaServer.quit = true; - System.out.println("I just set quit to true!"); - break; - } - - //todo: do as switch. - - if (comString.equalsIgnoreCase("NAME:")) { //todo: implement these as methods? - setName(in); - } - - if (comString.equalsIgnoreCase("NAMES")) { - printnames(); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void printnames() { - for (BudaClientThread t: BudaServer.Clients) { - System.out.println(t.name + " connected (#" + t.number + ")"); - } - } - - public void setName(InputStream in) throws IOException { - //byte[] namebyte = new byte[0]; - String nameString = ""; - int i; - while (true) { - i = in.read(); - if (i == 46) break; - nameString = nameString + (char) i; - } - this.name = nameString; - } - -} diff --git a/Übung/BudaServerClientStuff/src/BudaServer.java b/Übung/BudaServerClientStuff/src/BudaServer.java deleted file mode 100644 index 6e12148..0000000 --- a/Übung/BudaServerClientStuff/src/BudaServer.java +++ /dev/null @@ -1,25 +0,0 @@ - - -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.HashSet; - -public class BudaServer { - public static boolean quit = false; //todo: meaningfully implement this - public static HashSet Clients = new HashSet(); - static int connections = 0; - - public static void main(String[] args) { - ServerConnector ServC = new ServerConnector(); - Thread ServCThread = new Thread(ServC); - ServCThread.start(); - System.out.println("Server has entered its main loop"); - while (!quit) { - //Main server stuff goes here - } - //ServCThread.stop(); //todo: find some alternative for this. - System.out.println("stopping the main BudaServer thread."); - System.out.println("Quitting after the next connection is made."); - } -} diff --git a/Übung/BudaServerClientStuff/src/ClientListener.java b/Übung/BudaServerClientStuff/src/ClientListener.java deleted file mode 100644 index 6fe4639..0000000 --- a/Übung/BudaServerClientStuff/src/ClientListener.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.io.*; -import java.net.Socket; - -public class ClientListener implements Runnable{ - private final Socket sock; - - public ClientListener(Socket sock) { - this.sock = sock; - } - - public void run(){ - byte[] command = new byte[5]; - String comString; - - try { - InputStream in = sock.getInputStream(); - in.read(command); - System.out.println("Got a line!"); - comString = new String(command); - } catch (IOException e) { - e.printStackTrace(); - - } - } -} diff --git a/Übung/BudaServerClientStuff/src/ServerConnector.java b/Übung/BudaServerClientStuff/src/ServerConnector.java deleted file mode 100644 index 9833005..0000000 --- a/Übung/BudaServerClientStuff/src/ServerConnector.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; - -public class ServerConnector implements Runnable{ - public void run() { - try { - System.out.println( - "Warte auf Verbindungen auf Port 8090..."); - ServerSocket servSock = new ServerSocket(8090); - while (true) { - Socket socket = servSock.accept(); - System.out.println("got a connection: socket " + BudaServer.connections + socket.toString()); - BudaClientThread newClientThread = new BudaClientThread(++BudaServer.connections, socket); - BudaServer.Clients.add(newClientThread); - Thread bCT = new Thread(newClientThread); - bCT.start(); - } - } catch (IOException e) { - System.out.println("server got an error"); - System.err.println(e); - System.exit(1); - } - - - } -}