internal void CreateListenerConnection (Socket client)
        {
            lock (_activeConnections)
                {
                    if (_activeConnections.Count >= _maxConcurrentConnections)
                        Monitor.Wait (_activeConnections);

                    if (server_thread == null) return;    // Server was stopped while waiting

                    ClientConnection reader = new ClientConnection (this, client, sink);
                    Thread thread = new Thread (new ThreadStart (reader.ProcessMessages));
                    thread.Start();
                    thread.IsBackground = true;
                    _activeConnections.Add (thread);
                }
        }
        internal void InternalProcessMessage (ClientConnection connection, Stream stream)
        {
            // Reads the headers and the request stream

            Stream requestStream;
            ITransportHeaders requestHeaders;

            requestStream = UnixMessageIO.ReceiveMessageStream (stream, out requestHeaders, connection.Buffer);

/*            try {
                PeerCred cred = connection.Client.PeerCredential;
                requestHeaders["__uid"] = cred.UserID;
            } catch (Exception e) {
                Console.WriteLine ("Couldn't get the peer cred: " + e);
            }
*/
            // Pushes the connection object together with the sink. This information
            // will be used for sending the response in an async call.

            ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();
            sinkStack.Push(this, connection);

            ITransportHeaders responseHeaders;
            Stream responseStream;
            IMessage responseMsg;

            ServerProcessing proc = next_sink.ProcessMessage(sinkStack, null, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);

            switch (proc)
            {
            case ServerProcessing.Complete:
                UnixMessageIO.SendMessageStream (stream, responseStream, responseHeaders, connection.Buffer);
                stream.Flush ();
                break;

            case ServerProcessing.Async:
            case ServerProcessing.OneWay:
                break;
            }
        }