|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openarchitectureware.debug.communication.Connection
public class Connection
This class implements a socket connection model. "Packets" (units of information) can be transfered between two different virtual machines. During the initialisation of a socket connection a reader and a writer thread are established. This class can be used both on the sender and receiver side.
Constructor Summary | |
---|---|
Connection()
|
Method Summary | |
---|---|
void |
accept(int timeout)
the server listens for a client to connect, creates new reader and writer threads and sends a first handshake packet to test the communication |
void |
close()
close and dispose the socket and the (possibly waiting) sender thread |
void |
connect(int port)
the client establishes the connection here, creates new reader and writer threads and waits for a handshake packet to be received from the server |
boolean |
isConnected()
|
AbstractPacket |
listenForPacket(java.lang.Class<? extends AbstractPacket> type)
|
AbstractPacket |
listenForPacket(java.lang.Class<? extends AbstractPacket> type,
int refId)
|
protected AbstractPacket |
readPacket()
|
int |
sendPacket(AbstractPacket packet)
|
void |
startListeningSocket(int port)
create a new ServerSocket . |
protected void |
writePacket(AbstractPacket packet)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Connection()
Method Detail |
---|
public AbstractPacket listenForPacket(java.lang.Class<? extends AbstractPacket> type) throws java.io.InterruptedIOException
java.io.InterruptedIOException
public AbstractPacket listenForPacket(java.lang.Class<? extends AbstractPacket> type, int refId) throws java.io.InterruptedIOException
java.io.InterruptedIOException
public int sendPacket(AbstractPacket packet) throws java.io.IOException
java.io.IOException
public void startListeningSocket(int port) throws java.io.IOException
ServerSocket
.
port
- the communication port
java.io.IOException
public void accept(int timeout) throws java.io.IOException
timeout
-
java.io.IOException
public void connect(int port) throws java.io.IOException
port
-
java.io.IOException
public boolean isConnected()
public void close()
protected AbstractPacket readPacket() throws java.io.IOException
java.io.IOException
protected void writePacket(AbstractPacket packet) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |