Пример #1
0
 public static void Return(AsyncAcceptArgs args)
 {
     if (args != null)
     {
         AsyncAcceptArgsPool.Push(args);
     }
 }
Пример #2
0
 public Listener(Socket s, int maxAcceptOps = 10)
 {
     AcceptArgs   = new BlockingCollection <AsyncAcceptArgs>(maxAcceptOps);
     Sock         = s;
     MaxAcceptOps = maxAcceptOps;
     for (int i = 0; i < maxAcceptOps; i++)
     {
         AsyncAcceptArgs args = AsyncAcceptArgs.Get(this);
         AcceptArgs.Add(args);
     }
 }
Пример #3
0
        public void StartAccepting(string address, int port)
        {
            Sock.Bind(new IPEndPoint(IPAddress.Parse(address), port));
            Sock.Listen(MaxAcceptOps);

            while (true)
            {
                AsyncAcceptArgs args = AcceptArgs.Take();
                args.AcceptSocket = null;
                accept(args);
            }
        }
Пример #4
0
        public static AsyncAcceptArgs Get(Listener l)
        {
            AsyncAcceptArgs args = null;

            AsyncAcceptArgsPool.TryPop(out args);
            if (args == null)
            {
                args = new AsyncAcceptArgs();
            }
            args.listener = l;

            return(args);
        }