Package org.jrd.backend.communication
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 Summary
Fields Modifier and Type Field Description static StringDEFAULT_ADDRESS
-
Constructor Summary
Constructors Constructor Description Communicate(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(String line)Sends a line with request to agent.StringreadResponse()Method that reads agent's response.
-
-
-
Field Detail
-
DEFAULT_ADDRESS
public static final String DEFAULT_ADDRESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Communicate
public Communicate(String host, int port)
Constructor creates a socket on given port and saves the streams into class variables.- Parameters:
host- host nameport- port where we open the socket
-
-
Method Detail
-
close
public void close()
Closes a socket.
-
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
-
-