Exemplo n.º 1
0
        public void Connect(string ip, int port)
        {
            Debuger.Log("ip:{0}, port:{1}", ip, port);
            m_ip             = ip;
            m_port           = port;
            m_RemoteEndPoint = IPUtils.GetHostEndPoint(ip, port);

            m_SystemSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            m_SystemSocket.Bind(new IPEndPoint(IPAddress.Any, bindPort));

            m_Kcp = new KCP(0, HandleKcpSend);
            m_Kcp.NoDelay(1, 10, 2, 1);
            m_Kcp.WndSize(128, 128);

            Connected = true;

            m_ThreadRecv = new Thread(Thread_Recv)
            {
                IsBackground = true
            };
            m_ThreadRecv.Start();
        }