private bool readRequest() { int left = header.ContentLength - header.DataString.Length; int dataLen = 0; if (left > 0) { byte[] data = new byte[left]; try { dataLen = stream.Read(data, 0, left); if (dataLen == 0) { XmlRpcUtil.error("XmlRpcServerConnection::readRequest: Stream was closed"); return(false); } } catch (Exception ex) { XmlRpcUtil.error("XmlRpcServerConnection::readRequest: error while reading the rest of data ({0}).", ex.Message); return(false); } header.Append(Encoding.ASCII.GetString(data, 0, dataLen)); } // Otherwise, parse and dispatch the request XmlRpcUtil.log(XmlRpcUtil.XMLRPC_LOG_LEVEL.DEBUG, "XmlRpcServerConnection::readRequest read {0} bytes.", dataLen); if (!header.ContentComplete) { return(false); } _connectionState = ServerConnectionState.WRITE_RESPONSE; return(true); // Continue monitoring this source }
private bool readResponse() { int left = header.ContentLength - header.DataString.Length; int dataLen = 0; if (left > 0) { byte[] data = new byte[left]; try { var stream = socket.GetStream(); dataLen = stream.Read(data, 0, left); if (dataLen == 0) { XmlRpcUtil.log(XmlRpcUtil.XMLRPC_LOG_LEVEL.ERROR, "XmlRpcClient::readResponse: Stream was closed"); return(false); } } catch (Exception ex) { XmlRpcUtil.error("XmlRpcClient::readResponse: error while reading the rest of data ({0}).", ex.Message); return(false); } header.Append(Encoding.ASCII.GetString(data, 0, dataLen)); } if (header.ContentComplete) { // Otherwise, parse and dispatch the request XmlRpcUtil.log(XmlRpcUtil.XMLRPC_LOG_LEVEL.INFO, "XmlRpcClient::readResponse read {0} bytes.", _request.Length); _connectionState = ConnectionState.IDLE; return(false); // no need to continue monitoring because we're done reading the response } // Continue monitoring this source return(true); }