Package org.jrd.backend.communication
Class Communicate
- java.lang.Object
-
- org.jrd.backend.communication.Communicate
-
public class Communicate extends java.lang.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 private java.io.BufferedReader
commInput
private java.io.BufferedWriter
commOutput
private java.net.Socket
commSocket
static java.lang.String
DEFAULT_ADDRESS
-
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 void
close()
Closes a socket.void
println(java.lang.String line)
Sends a line with request to agent.java.lang.String
readResponse()
Method that reads agent's response.
-
-
-
Field Detail
-
commSocket
private java.net.Socket commSocket
-
commInput
private java.io.BufferedReader commInput
-
commOutput
private java.io.BufferedWriter commOutput
-
DEFAULT_ADDRESS
public static final java.lang.String DEFAULT_ADDRESS
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
Closes a socket.
-
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.IOException
Sends a line with request to agent.- Parameters:
line
- "CLASSES" or "BYTES className"- Throws:
java.io.IOException
- if the write operation fails
-
-