A Connection represents a bi-directional communication channel
between a debugger and a target VM. A Connection is created when
TransportService establishes a connection
and successfully handshakes with a target VM. A TransportService
implementation provides a reliable JDWP packet transportation service
and consequently a Connection provides a reliable flow of JDWP packets
between the debugger and the target VM. A Connection is stream oriented,
that is, the JDWP packets written to a connection are read by the target VM
in the order in which they were written. Similarly packets written
to a Connection by the target VM are read by the debugger in the
order in which they were written.
A connection is either open or closed. It is open upon creation,
and remains open until it is closed. Once closed, it remains closed,
and any attempt to invoke an I/O operation upon it will cause a
ClosedConnectionException to be thrown. A connection can
be tested by invoking the isOpen method.
A Connection is safe for access by multiple concurrent threads, although at most one thread may be reading and at most one thread may be writing at any given time.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| public abstract boolean | Returns: true if and only if this connection is openTells whether or not this connection is open. |
| public abstract byte[] | |
| public abstract void |
| Connection | back to summary |
|---|---|
| public Connection() Constructor for subclasses to call. | |
| close | back to summary |
|---|---|
| public abstract void close() throws IOException Closes this connection. If the connection is already closed then invoking this method
has no effect. After a connection is closed, any further attempt
calls to Any thread currently blocked in an I/O operation ( This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
| |
| isOpen | back to summary |
|---|---|
| public abstract boolean isOpen() Tells whether or not this connection is open.
| |
| readPacket | back to summary |
|---|---|
| public abstract byte[] readPacket() throws IOException Reads a packet from the target VM. Attempts to read a JDWP packet from the target VM. A read operation may block indefinitely and only returns when it reads all bytes of a packet, or in the case of a transport service that is based on a stream-oriented communication protocol, the end of stream is encountered. Reading a packet does not do any integrity checking on
the packet aside from a check that the length of the packet
(as indicated by the value of the Returns a byte array of a length equal to the length
of the received packet, or a byte array of length 0 when an
end of stream is encountered. If end of stream is encountered
after some, but not all bytes of a packet, are read then it
is considered an I/O error and an This method may be invoked at any time. If another thread has
already initiated a
| |
| writePacket | back to summary |
|---|---|
| public abstract void writePacket(byte[] pkt) throws IOException Writes a packet to the target VM. Attempts to write, or send, a JDWP packet to the target VM. A write operation only returns after writing the entire packet to the target VM. Writing the entire packet does not mean the entire packet has been transmitted to the target VM but rather that all bytes have been written to the transport service. A transport service based on a TCP/IP connection may, for example, buffer some or all of the packet before transmission on the network. The byte array provided to this method should be laid out
as per the
JDWP specification. That is, all fields in the packet
are in big endian order. The first byte, that is element
Writing a packet does not do any integrity checking on
the packet aside from checking the packet length. Checking
the packet length requires checking that the value of the
A write operation may block or may complete immediately. The exact circumstances when an operation blocks depends on the transport service. In the case of a TCP/IP connection to the target VM, the writePacket method may block if there is network congestion or there is insufficient space to buffer the packet in the underlying network system. This method may be invoked at any time. If another thread has already initiated a write operation upon this Connection then a subsequent invocation of this method will block until the first operation is complete.
| |