( begin auto-generated from Client_read.xml ) Returns a number between 0 and 255 for the next byte that's waiting in the buffer. Returns -1 if there is no byte, although this should be avoided by first cheacking available() to see if any data is available. ( end auto-generated ) @webref cli
()
| 388 | * @brief Returns a value from the buffer |
| 389 | */ |
| 390 | public int read() { |
| 391 | synchronized (bufferLock) { |
| 392 | if (bufferIndex == bufferLast) return -1; |
| 393 | |
| 394 | int outgoing = buffer[bufferIndex++] & 0xff; |
| 395 | if (bufferIndex == bufferLast) { // rewind |
| 396 | bufferIndex = 0; |
| 397 | bufferLast = 0; |
| 398 | } |
| 399 | return outgoing; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /** |