public void Connect(string host, int port) { var endpoint = IPAddress.Parse(host); mSocket = new Socket(endpoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); mSocket.Connect(endpoint, port); mKCP = new KCP((uint)(new Random().Next(1, Int32.MaxValue)), rawSend); // normal: 0, 40, 2, 1 // fast: 0, 30, 2, 1 // fast2: 1, 20, 2, 1 // fast3: 1, 10, 2, 1 mKCP.NoDelay(0, 30, 2, 1); mRecvBuffer.Clear(); }
public void Connect(string host, int port) { var endpoint = IPAddress.Parse(host); mSocket = new Socket(endpoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); mSocket.Connect(endpoint, port); mKCP = new KCP((uint)mConv, rawSend); // mKCP = new KCP((uint)UDPProtocolType.eUDPPT_CONNECT_REQ, rawSend); // normal: 0, 40, 2, 1 // fast: 0, 30, 2, 1 // fast2: 1, 20, 2, 1 // fast3: 1, 10, 2, 1 mKCP.NoDelay(0, 30, 2, 1); mRecvBuffer.Clear(); }
public void Connect(string host, int port, BlockCrypt b) { var endpoint = IPAddress.Parse(host); mSocket = new Socket(endpoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); mSocket.Connect(endpoint, port); mKCP = new KCP((uint)(new Random().Next(1, Int32.MaxValue)), rawSend); // normal: 0, 40, 2, 1 // fast: 0, 30, 2, 1 // fast2: 1, 20, 2, 1 // fast3: 1, 10, 2, 1 mKCP.NoDelay(0, 30, 2, 1); mRecvBuffer.Clear(); headerSize = 0; block = b; if (block != null) { headerSize += cryptHeaderSize; } mKCP.ReserveBytes(headerSize); }
public void Connect(string host, int port) { IPHostEntry hostEntry = Dns.GetHostEntry(host); if (hostEntry.AddressList.Length == 0) { throw new Exception("Unable to resolve host: " + host); } var endpoint = hostEntry.AddressList[0]; mSocket = new Socket(endpoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); mSocket.Connect(endpoint, port); RemoteAddress = (IPEndPoint)mSocket.RemoteEndPoint; LocalAddress = (IPEndPoint)mSocket.LocalEndPoint; mKCP = new KCP((uint)(new Random().Next(1, Int32.MaxValue)), rawSend); // normal: 0, 40, 2, 1 // fast: 0, 30, 2, 1 // fast2: 1, 20, 2, 1 // fast3: 1, 10, 2, 1 mKCP.NoDelay(0, 30, 2, 1); mKCP.SetStreamMode(true); mRecvBuffer.Clear(); }