Exemple #1
0
        public virtual void Connect(string host, int port)
        {
            disconnected = false;

            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            var task = new SocketConnectTask(host, port);

            task.Completed += ConnectCompleted;

            Socket.QueueConnect(task);
        }
Exemple #2
0
        public virtual void Connect(IPEndPoint ep)
        {
            disconnecting = false;
            disconnected  = false;

            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            var task = new SocketConnectTask(ep);

            task.Completed += ConnectCompleted;

            Socket.QueueConnect(task);
        }
Exemple #3
0
 public void QueueConnect(SocketConnectTask task)
 {
     lock (connQueue) connQueue.Enqueue(task);
 }
Exemple #4
0
 public static void QueueConnect(this Socket socket, SocketConnectTask task)
 {
     task.Socket    = socket ?? throw new ArgumentNullException("socket", "socket cannot be null");
     task.Exception = null;
     IO.QueueConnect(task);
 }