68 * transport service that is based on a stream-oriented |
68 * transport service that is based on a stream-oriented |
69 * communication protocol, the end of stream is encountered. |
69 * communication protocol, the end of stream is encountered. |
70 * |
70 * |
71 * <p> Reading a packet does not do any integrity checking on |
71 * <p> Reading a packet does not do any integrity checking on |
72 * the packet aside from a check that the length of the packet |
72 * the packet aside from a check that the length of the packet |
73 * (as indicated by the value of the <tt>length</tt> field, the |
73 * (as indicated by the value of the {@code length} field, the |
74 * first four bytes of the packet) is 11 or more bytes. |
74 * first four bytes of the packet) is 11 or more bytes. |
75 * If the value of the <tt>length</tt> value is less then 11 |
75 * If the value of the {@code length} value is less then 11 |
76 * then an <tt>IOException</tt> is thrown. |
76 * then an {@code IOException} is thrown. |
77 * |
77 * |
78 * <p> Returns a byte array of a length equal to the length |
78 * <p> Returns a byte array of a length equal to the length |
79 * of the received packet, or a byte array of length 0 when an |
79 * of the received packet, or a byte array of length 0 when an |
80 * end of stream is encountered. If end of stream is encountered |
80 * end of stream is encountered. If end of stream is encountered |
81 * after some, but not all bytes of a packet, are read then it |
81 * after some, but not all bytes of a packet, are read then it |
82 * is considered an I/O error and an <tt>IOException</tt> is |
82 * is considered an I/O error and an {@code IOException} is |
83 * thrown. The first byte of the packet is stored in element |
83 * thrown. The first byte of the packet is stored in element |
84 * <tt>0</tt> of the byte array, the second in element <tt>1</tt>, |
84 * {@code 0} of the byte array, the second in element {@code 1}, |
85 * and so on. The bytes in the byte array are laid out as per the |
85 * and so on. The bytes in the byte array are laid out as per the |
86 * <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html"> |
86 * <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html"> |
87 * JDWP specification</a>. That is, all fields in the packet |
87 * JDWP specification</a>. That is, all fields in the packet |
88 * are in big endian order as per the JDWP specification. |
88 * are in big endian order as per the JDWP specification. |
89 * |
89 * |
90 * <p> This method may be invoked at any time. If another thread has |
90 * <p> This method may be invoked at any time. If another thread has |
91 * already initiated a {@link #readPacket readPacket} on this |
91 * already initiated a {@link #readPacket readPacket} on this |
92 * connection then the invocation of this method will block until the |
92 * connection then the invocation of this method will block until the |
93 * first operation is complete. </p> |
93 * first operation is complete. |
94 * |
94 * |
95 * @return the packet read from the target VM |
95 * @return the packet read from the target VM |
96 * |
96 * |
97 * @throws ClosedConnectionException |
97 * @throws ClosedConnectionException |
98 * If the connection is closed, or another thread closes |
98 * If the connection is closed, or another thread closes |
121 * <p> The byte array provided to this method should be laid out |
121 * <p> The byte array provided to this method should be laid out |
122 * as per the <a |
122 * as per the <a |
123 * href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html"> |
123 * href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html"> |
124 * JDWP specification</a>. That is, all fields in the packet |
124 * JDWP specification</a>. That is, all fields in the packet |
125 * are in big endian order. The first byte, that is element |
125 * are in big endian order. The first byte, that is element |
126 * <tt>pkt[0]</tt>, is the first byte of the <tt>length</tt> field. |
126 * {@code pkt[0]}, is the first byte of the {@code length} field. |
127 * <tt>pkt[1]</tt> is the second byte of the <tt>length</tt> field, |
127 * {@code pkt[1]} is the second byte of the {@code length} field, |
128 * and so on. |
128 * and so on. |
129 * |
129 * |
130 * <p> Writing a packet does not do any integrity checking on |
130 * <p> Writing a packet does not do any integrity checking on |
131 * the packet aside from checking the packet length. Checking |
131 * the packet aside from checking the packet length. Checking |
132 * the packet length requires checking that the value of the |
132 * the packet length requires checking that the value of the |
133 * <tt>length</tt> field (as indicated by the first four bytes |
133 * {@code length} field (as indicated by the first four bytes |
134 * of the packet) is 11 or greater. Consequently the length of |
134 * of the packet) is 11 or greater. Consequently the length of |
135 * the byte array provided to this method, that is |
135 * the byte array provided to this method, that is |
136 * <tt>pkt.length</tt>, must be 11 or more, and must be equal |
136 * {@code pkt.length}, must be 11 or more, and must be equal |
137 * or greater than the value of the <tt>length</tt> field. If the |
137 * or greater than the value of the {@code length} field. If the |
138 * length of the byte array is greater than the value of |
138 * length of the byte array is greater than the value of |
139 * the <tt>length</tt> field then all bytes from element |
139 * the {@code length} field then all bytes from element |
140 * <tt>pkt[length]</tt> onwards are ignored. In other words, |
140 * {@code pkt[length]} onwards are ignored. In other words, |
141 * any additional bytes that follow the packet in the byte |
141 * any additional bytes that follow the packet in the byte |
142 * array are ignored and will not be transmitted to the target |
142 * array are ignored and will not be transmitted to the target |
143 * VM. |
143 * VM. |
144 * |
144 * |
145 * <p> A write operation may block or may complete immediately. |
145 * <p> A write operation may block or may complete immediately. |
150 * the packet in the underlying network system. |
150 * the packet in the underlying network system. |
151 * |
151 * |
152 * <p> This method may be invoked at any time. If another thread has |
152 * <p> This method may be invoked at any time. If another thread has |
153 * already initiated a write operation upon this Connection then |
153 * already initiated a write operation upon this Connection then |
154 * a subsequent invocation of this method will block until the first |
154 * a subsequent invocation of this method will block until the first |
155 * operation is complete. </p> |
155 * operation is complete. |
156 * |
156 * |
157 * @param pkt |
157 * @param pkt |
158 * The packet to write to the target VM. |
158 * The packet to write to the target VM. |
159 * |
159 * |
160 * @throws ClosedConnectionException |
160 * @throws ClosedConnectionException |
183 * will throw a {@link ClosedConnectionException}). |
183 * will throw a {@link ClosedConnectionException}). |
184 * |
184 * |
185 * <p> This method may be invoked at any time. If some other thread has |
185 * <p> This method may be invoked at any time. If some other thread has |
186 * already invoked it, however, then another invocation will block until |
186 * already invoked it, however, then another invocation will block until |
187 * the first invocation is complete, after which it will return without |
187 * the first invocation is complete, after which it will return without |
188 * effect. </p> |
188 * effect. |
189 * |
189 * |
190 * @throws java.io.IOException |
190 * @throws java.io.IOException |
191 * If an I/O error occurs |
191 * If an I/O error occurs |
192 */ |
192 */ |
193 public abstract void close() throws IOException; |
193 public abstract void close() throws IOException; |
194 |
194 |
195 /** |
195 /** |
196 * Tells whether or not this connection is open. </p> |
196 * Tells whether or not this connection is open. |
197 * |
197 * |
198 * @return <tt>true</tt> if, and only if, this connection is open |
198 * @return {@code true} if and only if this connection is open |
199 */ |
199 */ |
200 public abstract boolean isOpen(); |
200 public abstract boolean isOpen(); |
201 } |
201 } |