public Result loadAssembly(string file)
        {
            StreamedMessageUtils<NetworkStream> messenger = new StreamedMessageUtils<NetworkStream>(this.Client.GetStream());

            var request = Request.CreateLoadAssemblyRequest(file);
            byte[] outgoing_buffer = request.Serialize();
            messenger.writeMessage(outgoing_buffer);

            byte[] incoming_buffer = messenger.readMessage();
            var result = Result.Deserialize(incoming_buffer);

            return result;
        }
        public Result evaluate(string input)
        {
            StreamedMessageUtils<NetworkStream> messenger = new StreamedMessageUtils<NetworkStream>(this.Client.GetStream());

            var request = Request.CreateEvaluationRequest(input);
            byte[] outgoing_buffer = request.Serialize();
            messenger.writeMessage(outgoing_buffer);

            byte[] incoming_buffer = messenger.readMessage();
            var result = Result.Deserialize(incoming_buffer);

            return result;
        }
        public Result getVariables()
        {
            StreamedMessageUtils<NetworkStream> messenger = new StreamedMessageUtils<NetworkStream>(this.Client.GetStream());

            var request = Request.CreateGetVariablesRequest();
            byte[] outgoing_buffer = request.Serialize();
            messenger.writeMessage(outgoing_buffer);

            byte[] incoming_buffer = messenger.readMessage();
            var result = Result.Deserialize(incoming_buffer);

            return result;
        }
        private void handleClientComm(object client)
        {
            TcpClient tcpClient = (TcpClient)client;

            var messenger = new StreamedMessageUtils<NetworkStream>(tcpClient.GetStream());

            while (true)
            {

                try
                {
                    //blocks until a client sends a message
                    byte[] buffer = messenger.readMessage();
                    var request = Request.Deserialize(buffer);
                    Result result;
                    if (request.Type == RequestType.Evaluate) {
                        result = this.Repl.evaluate(request.Code);
                    } else if (request.Type == RequestType.LoadAssembly) {
                        result = this.Repl.loadAssembly(request.AssemblyToLoad);
                    } else if (request.Type == RequestType.Variables) {
                        result = this.Repl.getVariables();
                    } else if (request.Type == RequestType.Usings) {
                        result = this.Repl.getUsings();
                    } else {
                        Console.WriteLine("Received unexpected request type {0}",request.Type);
                        break;
                    }

                    byte[] output_buffer = result.Serialize();
                    messenger.writeMessage(output_buffer);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unexpected error occurred: " + e.Message);
                    break;
                }
                Console.Out.Flush();
                Console.Error.Flush();
            }

            tcpClient.Close();
        }