|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectsimpleNetworking.Client
public class Client
A simple Client that you can use in your programs. It has methods for: -- reading from the Server -- writing to the Server -- closing its resources It does a minimal-security validation protocol with the Server (who must use the Server's side of that protocol).
Constructor Summary | |
---|---|
Client(String serverHostName)
Connects to the given Server, getting a Socket, and prepares for reading/writer to the Server based on that Socket. |
Method Summary | |
---|---|
void |
close()
Closes the resources associated with this Client. |
(package private) void |
finishUpFailedConstruction(Throwable exception,
String serverHostName,
String errorMessage)
Something went wrong in constructing this Client. |
String |
readLine()
Returns the next line available from the Server, stripping the terminating newline. |
protected boolean |
validate()
To validate a proposed Client: -- This Client sends the (announced) password to the Server. |
void |
writeLine(String stringToWrite)
Sends the given String, appending a newline to it, to the Server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Client(String serverHostName) throws SocketException
serverHostName
- Name (e.g. "mutchler-3.rose-hulman.edu")
or IP address (e.g. "137.112.250.33")
of the Server to which you want to connect.
SocketException
Method Detail |
---|
public String readLine() throws IOException
IOException
- if an IO error occurs while reading.public void writeLine(String stringToWrite) throws IOException
stringToWrite
- String to send (with a newline appended) to the Server.
IOException
- if an error occurs while writing.public void close()
protected boolean validate()
void finishUpFailedConstruction(Throwable exception, String serverHostName, String errorMessage) throws SocketException
exception
- that was thrown by the failed construction of this Client.errorMessage
- to display in a message dialog.serverHostName
- to which this Client tried to connect.
SocketException
- so that the caller knows that construction failed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |