Ejemplo n.º 1
0
        protected override void serveClient(Protocol.BaseProcessor processor)
        {
            Thread t = new Thread(threadproc);

            t.Start(processor);
            //client_threads.Add(t);
        }
Ejemplo n.º 2
0
 virtual public void Serve()
 {
     while (true)
     {
         ITransport             transport = transportFactory.Accept();
         Protocol.BaseProcessor processor = processorFactory.Create(transport);
         serveClient(processor);
     }
 }
Ejemplo n.º 3
0
        public override void Serve()
        {
            TcpListener listener = ((SocketTransportFactory)transportFactory).listener;
            IPEndPoint  ep       = (IPEndPoint)listener.LocalEndpoint;

            System.Console.Out.Write("AGNOS\n{0}\n{1}\n", ep.Address, ep.Port);
            System.Console.Out.Flush();
            // XXX: i can't seem to find a way to actually close the underlying
            // filedesc, so we have to use readline() instead of read()
            // because read() will block indefinitely
            System.Console.Out.Close();
            ITransport transport = transportFactory.Accept();

            transportFactory.Close();

            Protocol.BaseProcessor processor = processorFactory.Create(transport);
            handleClient(processor);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// the basic client handler -- calls processor.process in a loop,
 /// until the client disconnects
 /// </summary>
 /// <param name="processor">
 /// the processor instance that represents the client
 /// </param>
 protected static void handleClient(Protocol.BaseProcessor processor)
 {
     try
     {
         while (true)
         {
             processor.process();
         }
     }
     catch (EndOfStreamException)
     {
         // finish on EOF
     }
     catch (IOException)
     {
         // usually a "connection reset by peer" -- just clean up nicely,
         // the connection is dead anyway
     }
     finally
     {
         processor.Close();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// implement this method to serve the client in whatever which way
 /// is appropriate (blocking, threaded, forking, threadpool, ...)
 /// </summary>
 /// <param name="processor">
 /// the processor instance that represents the client
 /// </param>
 protected abstract void serveClient(Protocol.BaseProcessor processor);
Ejemplo n.º 6
0
 protected override void serveClient(Protocol.BaseProcessor processor)
 {
     throw new InvalidOperationException("should never be called");
 }
Ejemplo n.º 7
0
 protected override void serveClient(Protocol.BaseProcessor processor)
 {
     handleClient(processor);
 }