Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| example [2023/03/09 16:05] – epsatisep | example [2024/06/19 19:51] (current) – epsatisep | ||
|---|---|---|---|
| Line 141: | Line 141: | ||
| DESCRIPTION: | DESCRIPTION: | ||
| </ | </ | ||
| + | |||
| + | ==== Code Listing Example ==== | ||
| + | The server code is presented in Listing | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | public class CheckersServer { | ||
| + | private static final int PORT = 12345; | ||
| + | private static char[][] board; | ||
| + | private static List< | ||
| + | public static void main(String[] args) { | ||
| + | board = new char[8][8]; | ||
| + | initializeBoard(); | ||
| + | try (ServerSocket serverSocket = new ServerSocket(PORT)) { | ||
| + | System.out.println(" | ||
| + | while (true) { | ||
| + | Socket clientSocket = serverSocket.accept(); | ||
| + | ClientHandler clientHandler = new ClientHandler(clientSocket); | ||
| + | clients.add(clientHandler); | ||
| + | new Thread(clientHandler).start(); | ||
| + | } | ||
| + | } catch (IOException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | |||
| ===== Bibliography ====== | ===== Bibliography ====== | ||
| + | |||