Beispiel #1
0
        public static void QueueConnect(this Socket socket, SocketConnectTask task)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket", "socket cannot be null");
            }

            task.Socket    = socket;
            task.Exception = null;
            IO.QueueConnect(task);
        }
Beispiel #2
0
        private void ExecuteConnect()
        {
            IOBuffer          args = null;
            SocketConnectTask task = null;

            lock (connPool)
                lock (acceptQueue) {
                    if (connPool.Count == 0 || connQueue.Count == 0)
                    {
                        return;
                    }

                    args = connPool.Pop();
                    task = connQueue.Dequeue();

                    task.Execute(args);
                }
        }
Beispiel #3
0
        public void Connect(IPEndPoint ep, Action <ISocket> complete)
        {
            disconnected = false;

            if (socket == null)
            {
                socket   = SocketManager.CreateTcp(AddressFamily.InterNetwork);
                outQueue = new ConcurrentQueue <IPacket>();
                monitor.Start();
            }

            SocketConnectTask task = new SocketConnectTask(ep);

            task.UserToken  = complete;
            task.Completed += ConnectCompleted;

            socket.QueueConnect(task);
        }
Beispiel #4
0
 public void QueueConnect(SocketConnectTask task)
 {
     lock (connQueue) connQueue.Enqueue(task);
 }