Ejemplo n.º 1
0
        /// <summary>
        /// 打开连接
        /// </summary>
        public void Open()
        {
            UnityEngine.NetworkReachability state = UnityEngine.Application.internetReachability;
            if (state != UnityEngine.NetworkReachability.NotReachable)
            {
                _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                try
                {
                    _socket.Connect(_host, _port);
                }
                catch
                {
                    //socket.Dispose();
                    _socket = null;
                    throw;
                }
                _netview = CreateThread();

                _thread = new Thread(new ThreadStart(CheckReceive));
                _thread.Start();


            }

        }
Ejemplo n.º 2
0
        /// <summary>
        /// 打开连接
        /// </summary>
        public void Open()
        {
            UnityEngine.NetworkReachability state = UnityEngine.Application.internetReachability;
            if (state != UnityEngine.NetworkReachability.NotReachable)
            {
                _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                try
                {
                    _socket.Connect(_host, _port);
                }
                catch
                {
                    //socket.Dispose();
                    _socket = null;
                    throw;
                }
                _netview = CreateThread();

                _thread = new Thread(new ThreadStart(CheckReceive));
                _thread.Start();
            }
        }