Browse Source

added Server methods

master
MrTob 1 year ago
parent
commit
772fd35979
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      src/xyz/nextn/Server.java

+ 28
- 0
src/xyz/nextn/Server.java View File

@@ -1,4 +1,32 @@
package xyz.nextn;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
private ServerSocket serverSocket;

public void start(int port) throws IOException {
serverSocket = new ServerSocket(port);
while (true)
new EchoClientHandler(serverSocket.accept()).start();
}

public void stop() throws IOException {
serverSocket.close();
}

private static class EchoClientHandler extends Thread {
private Socket clientSocket;
private PrintWriter out;
private BufferedReader in;

public EchoClientHandler(Socket socket) {
this.clientSocket = socket;
}
}

}

Loading…
Cancel
Save