example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
example [2024/02/16 19:20] – external edit 127.0.0.1example [2024/06/19 19:50] (current) epsatisep
Line 130: Line 130:
  
 {{tasks>[namespace]?all&[flags]}} {{tasks>[namespace]?all&[flags]}}
 +
 +==== Code Listing Example ====
 +The server code is presented in Listing  {{ref>clabel0}}.
 +
 +<codeblock clabel0>
 +<caption>Server-side code </caption>
 +<code>
 +    public class CheckersServer {
 +    private static final int PORT = 12345;
 +    private static char[][] board;
 +    private static List<ClientHandler> clients = new ArrayList<>();
 +    public static void main(String[] args) {
 +        board = new char[8][8];
 +        initializeBoard();
 +        try (ServerSocket serverSocket = new ServerSocket(PORT)) {
 +            System.out.println("Checkers Server is running...");
 +            while (true) {
 +                Socket clientSocket = serverSocket.accept();
 +                ClientHandler clientHandler = new ClientHandler(clientSocket);
 +                clients.add(clientHandler);
 +                new Thread(clientHandler).start();
 +            }
 +        } catch (IOException e) {
 +            e.printStackTrace();
 +        }
 +    }
 +</code>    
 +</codeblock>
 +
  
 ==== AV Task Box Plugin Usage Example ==== ==== AV Task Box Plugin Usage Example ====
  • example.txt
  • Last modified: 2024/06/19 19:50
  • by epsatisep