예제 #1
0
        /// <summary>
        /// 连接服务器,初始化CCClientSocket,开始异步连接
        /// </summary>
        /// <param name="host">端口</param>
        /// <param name="port">ip地址</param>
        /// <returns>是否连接成功</returns>
        public bool Connect(string host, int port)
        {
            this.Close();
            this.m_oSocket = new CClientSocket();
            bool result;

            if (!this.m_oSocket.Init(this.m_dwSendBuffSize, this.m_dwRecvBuffSize, this, this.m_oBreaker))
            {
                this.m_oSocket = null;
                result         = false;
            }
            else
            {
                result = this.m_oSocket.Connect(host, port);
            }
            return(result);
        }