private int readMessage() throws IOException {
            int totalBytesRead = 0;
            while (!stopping && totalBytesRead < messageSize) {
                try {
                    int remaining = messageSize - totalBytesRead;
                    int bytesRead = inputStream.read(buffer, totalBytesRead, remaining);
                    if (bytesRead == -1) {
                        break;
                    }
                    totalBytesRead += bytesRead;
                } catch (SSLException e) {
                    if (e.getCause() instanceof EOFException) {
                        break;
                    }
                    throw e;
                } catch (ClosedChannelException e) {
                    // Thrown for channel-based sockets. Just treat like EOF.
                    break;
                } catch (SocketException e) {
                    // The socket was broken. Just treat like EOF.
                    break;
                }
            }
            return totalBytesRead;
        }
A {@link MessageProcessor} that simply echos back the received message to the client.
benchmark-base/src/main/java/org/conscrypt/ServerEndpoint.java