internal void InternalProcessMessage(Stream network_stream)
        {
            try {
                string uri;
                IIOPMessage.MessageType msg_type;
                MemoryStream            msg_stream;

                msg_stream = IIOPMessage.ReceiveMessageStream(network_stream,
                                                              out msg_type, out uri);
                if (msg_type != IIOPMessage.MessageType.Request)
                {
                    throw new RemotingException("received wrong message type");
                }

                TransportHeaders headers = new TransportHeaders();
                headers ["_requestUri"] = uri;

                IMessage          resp_message;
                ITransportHeaders resp_headers;
                Stream            resp_stream;
                ServerProcessing  res = next_sink.ProcessMessage(null, null, headers, msg_stream,
                                                                 out resp_message, out resp_headers,
                                                                 out resp_stream);

                switch (res)
                {
                case ServerProcessing.Complete:

                    Exception e = ((IMethodReturnMessage)resp_message).Exception;
                    if (e != null)
                    {
                        // we handle exceptions in the transport channel
                        IIOPMessage.SendExceptionMessage(network_stream, e.ToString());
                    }
                    else
                    {
                        // send the response
                        IIOPMessage.SendMessageStream(network_stream,
                                                      (MemoryStream)resp_stream,
                                                      IIOPMessage.MessageType.Response,
                                                      null);
                    }
                    break;

                case ServerProcessing.Async:
                case ServerProcessing.OneWay:
                    throw new NotImplementedException();
                }
            } catch (Exception e) {
                IIOPMessage.SendExceptionMessage(network_stream, e.ToString());
            }
        }
        public void ProcessMessage(IMessage msg,
                                   ITransportHeaders requestHeaders,
                                   Stream requestStream,
                                   out ITransportHeaders responseHeaders,
                                   out Stream responseStream)
        {
            // get a network stream
            tcpclient.Connect(host, port);
            Stream network_stream = tcpclient.GetStream();

            // send the message
            IIOPMessage.SendMessageStream(network_stream, (MemoryStream)requestStream,
                                          IIOPMessage.MessageType.Request,
                                          object_uri);

            // read the response fro the network an copy it to a memory stream
            IIOPMessage.MessageType msg_type;
            string       uri;
            MemoryStream mem_stream =
                IIOPMessage.ReceiveMessageStream(network_stream, out msg_type, out uri);

            // close the stream
            tcpclient.Close();

            switch (msg_type)
            {
            case IIOPMessage.MessageType.Response:
                //fixme: read response message
                responseHeaders = null;

                responseStream = mem_stream;

                break;

            default:
                throw new Exception("unknown response mesage header");
            }
        }