public bool Bind(IPEndPoint ep) { bool pret = Init(); Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Socket.Blocking = false; Socket.ReceiveBufferSize = NetConstants.SocketBufferSize; Socket.SendBufferSize = NetConstants.SocketBufferSize; Socket.DontFragment = true; if (!BindSocket(Socket, ep)) { return(false); } m_running = true; ////////////////////////////////////////////////////////////////////////// m_kcp = new KCP(NetConstants.Kcp_Con_V, (byte[] buf, int size) => { //DebugHandler.Log("buf+"+ size); SendTo(buf.CloneRange(0, size), 0, size); }); m_kcp.NoDelay(1, 10, 2, 1); m_kcp.WndSize(NetConstants.PacketSizeLimit, NetConstants.PacketSizeLimit); m_kcp.SetMtu(NetConstants.Kcp_Mtu); return(pret); }
// public KcpPeer() // { // Console.WriteLine("KcpPeer"); // } // ~KcpPeer() // { // Console.WriteLine("~KcpPeer"); // } public virtual void Init(KcpSession session) { m_KcpSession = session; m_kcp = new KCP(NetConstants.Kcp_Con_V, (byte[] buf, int size) => { KcpSession.Send(buf, 0, size); }); m_kcp.NoDelay(1, 10, 2, 1); m_kcp.WndSize(NetConstants.PacketSizeLimit, NetConstants.PacketSizeLimit); m_kcp.SetMtu(NetConstants.Kcp_Mtu); }