Skip to content
Snippets Groups Projects
Verified Commit 17cfe804 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Remove multithreading - it will be implemented during laboratory.

parent 7e274a11
No related merge requests found
......@@ -21,10 +21,12 @@ public class ServerApp {
}
protected void listen() {
System.out.println("Server started and ready to connection");
try {
while (true) {
Socket socketFromClient = server.accept();
new Thread(new ServerComunicator(socketFromClient)).start();
System.out.println("Client connected: " + socketFromClient.getInetAddress());
new ServerComunicator(socketFromClient).handle();
}
} catch (Exception e) {
e.printStackTrace();
......
......@@ -7,7 +7,7 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
public class ServerComunicator implements Runnable{
public class ServerComunicator {
private Socket socket;
......@@ -15,8 +15,7 @@ public class ServerComunicator implements Runnable{
this.socket = socketFromCliernt;
}
@Override
public void run() {
public void handle() {
try (BufferedReader readerFromClentSocket = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedWriter writerToClentSocket = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))) {
String lineRededClient;
......@@ -35,10 +34,5 @@ public class ServerComunicator implements Runnable{
} catch (IOException e) {
e.printStackTrace();
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment