|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectConnection
public class Connection
The Connection class manages a connection with a Soldat server
Constructor Summary | |
---|---|
Connection(ConnectionListener listener)
Creates a new Connection object tied to the specified ConnectionListener |
Method Summary | |
---|---|
void |
connect(java.lang.String address,
int port)
Connects to the server with the specified address, on the specified port |
void |
disconnect()
Closes any open connection to a Soldat server |
boolean |
isClosed()
Tests whether or not the connection socket is closed |
boolean |
isConnected()
Tests whether or not the connection socket is connected |
int |
read()
Reads a single character from an open connection. |
java.lang.String |
readString()
Reads characters up to and including a newline character from the connection socket |
void |
sendData(java.lang.String data)
Sends data to the connected Soldat server |
void |
skip(int num)
Skips the specified number of bytes of data waiting on the connection socket |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Connection(ConnectionListener listener)
ConnectionListener
listener
- the object to receive events generated by the connectionMethod Detail |
---|
public void connect(java.lang.String address, int port) throws java.net.UnknownHostException, java.io.IOException
address
- the address of the Soldat server, in dotted IP format
(X.X.X.X)port
- the port number to connect to (23073 by default)
java.net.UnknownHostException
java.io.IOException
public void disconnect()
public void sendData(java.lang.String data)
data
- the data to sendpublic boolean isClosed()
public boolean isConnected()
public int read() throws java.io.IOException
java.io.IOException
- if an input or output error occurredpublic java.lang.String readString() throws java.io.IOException
java.io.IOException
- if an input or output error occurredpublic void skip(int num) throws java.io.IOException
num
- the number of bytes to skip
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |