                 }
             }
 
-            while messageParserState == .decodingData && inputStream.streamStatus == .open {
+            while messageParserState == .decodingData && input.streamStatus == .open {
                 switch messageType {
                 case .publish:
                     guard messageLength > 0 else {

            messageBuffer.deallocate(capacity: options.bufferSize)
        }

        while inputStream.streamStatus == .open {
            while messageParserState == .decodingHeader && inputStream.streamStatus == .open {
                let count = inputStream.read(messageBuffer, maxLength: 1)
                if count == 0 {
                    break
                } else if count < 0 {


    // MARK: - Socket connection

    private func openStreams() -> (input: InputStream, output: OutputStream)? {
        var inputStream: InputStream?
        var outputStream: OutputStream?

        Stream.getStreamsToHost(withName: host,
                                port: options.concretePort,
                                inputStream: &inputStream,
                                outputStream: &outputStream)

        guard let input = inputStream, let output = outputStream else {
            return nil
