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:21] – external edit 127.0.0.1example [2024/06/19 19:52] (current) epsatisep
Line 141: Line 141:
 DESCRIPTION: Perform a market research concerning your product. DESCRIPTION: Perform a market research concerning your product.
 </task> </task>
 +
 +==== 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>
 +
 ===== Bibliography ====== ===== Bibliography ======
  • example.1708111260.txt.gz
  • Last modified: 2024/02/16 19:21
  • by 127.0.0.1