Skip to content
Snippets Groups Projects
Commit 5c5dabbc authored by Elrabu's avatar Elrabu
Browse files

Fix: Test server can now store integer variables.

parent 47c8e7bf
No related branches found
No related tags found
3 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development
package de.hdm_stuttgart.battlearena.Model.Multiplayer.TestServer;
import de.hdm_stuttgart.battlearena.Model.Multiplayer.ConnectionHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.net.*;
import java.io.*;
public class Server {
private ServerSocket serverSocket;
private static BufferedReader px;
public static void main(String[] args) throws IOException {
Server server = new Server();
server.start(4444);
server.start("lolcalhost",4444);
}
public void start(int port) throws IOException {
public void start(String lolcalhost, int port) throws IOException {
serverSocket = new ServerSocket(port);
while (true)
new EchoClientHandler(serverSocket.accept()).start();
......@@ -33,6 +27,7 @@ public class Server {
private Socket clientSocket;
private PrintWriter out;
private BufferedReader in;
private static BufferedReader px;
public EchoClientHandler(Socket socket) {
this.clientSocket = socket;
......@@ -47,7 +42,7 @@ public class Server {
px = in;
while (true) {
System.out.println("Received message from client: " + inputLine);
System.out.println("Received message from client: " + px.readLine());
if (inputLine.equals(0)) {
out.println("bye");
......@@ -58,7 +53,7 @@ public class Server {
out.println(px);
out.flush();
System.out.println("Sent response to client: " + px);
System.out.println("Sent response to client: " + px.readLine());
}
} catch (SocketException e) {
System.out.println("Client connection reset.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment