Class Communicate

java.lang.Object
org.jrd.backend.communication.Communicate

public class Communicate extends Object
This class opens a socket and contain methods for read and write to socket IS/OS.
  • Field Details

  • Constructor Details

    • Communicate

      public Communicate(String host, int port)
      Constructor creates a socket on given port and saves the streams into class variables.
      Parameters:
      host - host name
      port - port where we open the socket
  • Method Details

    • close

      public void close()
      Closes a socket.
    • trimReadLine

      private String trimReadLine() throws IOException
      Throws:
      IOException
    • readResponse

      public String readResponse()
      Method that reads agent's response.
      Returns:
      "ERROR" in case of fail or corresponding bytes or class names
    • println

      public void println(String line) throws IOException
      Sends a line with request to agent.
      Parameters:
      line - "CLASSES" or "BYTES className"
      Throws:
      IOException - if the write operation fails