Package org.jrd.backend.communication
Class Communicate
- java.lang.Object
-
- org.jrd.backend.communication.Communicate
-
public class Communicate extends java.lang.ObjectThis class opens a socket and contain methods for read and write to socket IS/OS.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.BufferedReadercommInputprivate java.io.BufferedWritercommOutputprivate java.net.SocketcommSocket
-
Constructor Summary
Constructors Constructor Description Communicate(java.lang.String host, int port)Constructor creates a socket on given port and saves the streams into class variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes a socket.voidprintln(java.lang.String line)Sends a line with request to agent.java.lang.StringreadResponse()Method that reads agent's response.private java.lang.StringtrimReadLine()
-
-
-
Method Detail
-
close
public void close()
Closes a socket.
-
trimReadLine
private java.lang.String trimReadLine() throws java.io.IOException- Throws:
java.io.IOException
-
readResponse
public java.lang.String readResponse()
Method that reads agent's response.- Returns:
- "ERROR" in case of fail or corresponding bytes or class names
-
println
public void println(java.lang.String line) throws java.io.IOExceptionSends a line with request to agent.- Parameters:
line- "CLASSES" or "BYTES className"- Throws:
java.io.IOException- if the write operation fails
-
-