Exemplo n.º 1
0
        public bool Connect(EndPoint ipEnd)
        {
            var asyncargs = asyncpool.Pop();

            var token = new usertoken(this, null);

            asyncargs.RemoteEndPoint = ipEnd;
            asyncargs.UserToken      = token;
            try
            {
                bool willRaiseEvent = socket.ConnectAsync(asyncargs);
                if (!willRaiseEvent)
                {
                    ProcessConnect(asyncargs);
                }
                return(true);
            }
            catch
            {
                asyncargs.UserToken = null;
                asyncpool.Push(asyncargs);
            }
            return(false);
        }