Example #1
0
        public static void ConnectServer(string host, int port)
        {
            if (m_client != null)
            {
                return;
            }
            m_client = new TcpClient();

            m_client.NoDelay = true;
            try
            {
                m_client.Connect(host, port);
                MessageBox.Show("连ζŽ₯成功");
                m_client.Client.SendTimeout = 30000;
                //m_sampleDict.Clear();
                m_strDict.Clear();
                m_key = 0;
                ns    = m_client.GetStream();
                bw    = new MBinaryWriter(ns);
                br    = new BinaryReader(ns);

                m_sendThread = new Thread(new ThreadStart(DoSendMessage));
                m_sendThread.Start();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                Close();
            }
        }
        public static void ConnectServer(string host, int port)
        {
            if (m_client != null)
            {
                return;
            }
            m_client = new TcpClient();

            m_client.NoDelay = true;
            try
            {
                m_client.Connect(host, port);

                UnityEngine.Debug.Log("<color=#00ff00>connect success</color>");
                m_client.Client.SendTimeout = 30000;
                //m_sampleDict.Clear();
                m_strDict.Clear();
                m_key = 0;
                ns    = m_client.GetStream();
                bw    = new MBinaryWriter(ns);
                br    = new BinaryReader(ns);

                m_sendThread = new Thread(new ThreadStart(DoSendMessage));
                m_sendThread.Start();
                m_receiveThread = new Thread(new ThreadStart(DoRecieveMessage));
                m_receiveThread.Start();
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log(e);
                Close();
            }
        }