From 107cc34895c25dad9c8cf7311d26753d9ee03533 Mon Sep 17 00:00:00 2001 From: michelefiori Date: Mon, 26 Feb 2024 17:36:06 +0100 Subject: [PATCH] Switched comments to english --- src/main/java/TCPClient.java | 14 +++++++------- src/main/java/TCPServer.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/TCPClient.java b/src/main/java/TCPClient.java index c644169..84e8814 100644 --- a/src/main/java/TCPClient.java +++ b/src/main/java/TCPClient.java @@ -6,29 +6,29 @@ class TCPClient { String sentence; String modifiedSentence; - /* Inizializza l'input stream (da tastiera) */ + /* Initialize input stream */ BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); - /* Inizializza una socket client, connessa al server */ + /* Initialize a client socket, connected to the server */ Socket clientSocket = new Socket("localhost", 6789); - /* Inizializza lo stream di output verso la socket */ + /* Initialize output stream towards the socket */ DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); - /* Inizializza lo stream di input dalla socket */ + /* Initialize input stream from the socket */ BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); - /* Legge una linea da tastiera */ + /* Read an input line */ sentence = inFromUser.readLine(); - /* Invia la linea al server */ + /* Send the line to the server*/ outToServer.writeBytes(sentence + '\n'); - /* Legge la risposta inviata dal server (linea terminata da \n) */ + /* Read response from the server (string ending with '\n') */ modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); diff --git a/src/main/java/TCPServer.java b/src/main/java/TCPServer.java index 5e565ed..a322092 100644 --- a/src/main/java/TCPServer.java +++ b/src/main/java/TCPServer.java @@ -8,32 +8,32 @@ class TCPServer { String clientSentence; String capitalizedSentence; - /* Crea una "listening socket" sulla porta specificata */ + /* Create a "listening socket" on the specified port */ ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { /* - * Viene chiamata accept (bloccante). - * All'arrivo di una nuova connessione crea una nuova - * "established socket" + * Call to accept function (blocking call). + * When a new connection arrives a new "established socket" is created */ Socket connectionSocket = welcomeSocket.accept(); - /* Inizializza lo stream di input dalla socket */ + /* Initialize input stream from the socket */ BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); - /* Inizializza lo stream di output verso la socket */ + /* Initialize output stream towards the socket */ DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); - /* Legge una linea (terminata da \n) dal client */ + /* Read a line (ending with '\n') from the client */ clientSentence = inFromClient.readLine(); + /* Build the response */ capitalizedSentence = clientSentence.toUpperCase() + '\n'; - /* Invia la risposta al client */ + /* Send the response to the client */ outToClient.writeBytes(capitalizedSentence); connectionSocket.close(); -- 2.18.1