|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.marringtons.net.ClientSocket
A client TCP/IP Socket class for simplified basic network I/O.
ClientSocket client = new ClientSocket( port); client.writeLine( "Command"); String response = client.readLine(); client.close();
| Constructor Summary | |
ClientSocket(InetAddress inetAddress,
int port)
Open a client socket on the local server ready for reading and writing. |
|
ClientSocket(int port)
Open a client socket on the local server ready for reading and writing. |
|
ClientSocket(String hostName,
int port)
Open a client socket on the local server ready for reading and writing. |
|
| Method Summary | |
void |
close()
Close a socket and release all resources. |
void |
flush()
The data from a write or writeLine will not be sent unless flush() is called. |
BufferedReader |
getReader()
Return the reader so that programs that want to get data directly can do so (i.e. |
boolean |
isAlive()
See if the connection is still alive. |
String |
read(int characters)
Synchronous read of an expected number of characters from the socket server. |
String |
readLine()
Read a text line from the client socket. |
void |
write(String string)
Send a string to the socket server |
void |
writeLine(String line)
Send a line (including training linefeed) to the socket server. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ClientSocket(int port)
throws IOException
port - to connect to.
IOException
public ClientSocket(String hostName,
int port)
throws IOException,
UnknownHostException
hostName - name or IP as a stringport - to connect to.
IOException
UnknownHostException
public ClientSocket(InetAddress inetAddress,
int port)
throws IOException
inetAddress - port - to connect to.
IOException| Method Detail |
public void close()
public boolean isAlive()
public String read(int characters)
throws IOException
characters - to read
IOException
public String readLine()
throws IOException
IOException
public void write(String string)
throws IOException
string - to write to the port.
IOExceptionpublic void flush()
public void writeLine(String line)
throws IOException
line - to write to the port.
IOExceptionpublic BufferedReader getReader()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||