public void Close() { if (socket != null) { socket.Close(); } }
public override void Disconnect() { LoggerManager.Instance.Debug("Logic call Disconnect"); object obj = statusLock; Monitor.Enter(obj); try { connectionStatus = ConnectionStatus.ClosedByLogic; } finally { Monitor.Exit(obj); } if (connection != null) { connection.Disconnect(null); connection = null; } if (socket != null) { socket.Close(); } }
public void Close(string reason) { if (mSocket != null) { mSocket.Close(reason); } }
private static void DoUdp(string[] args) { if (args.Length == 0) { return; } else if (args[0].ToLower() == "open") { if (isUdpOpen) { Console.WriteLine("Udp already opened"); } else { isUdpOpen = true; } } else if (args[0].ToLower() == "close") { if (isUdpOpen) { //stop listener threads } else { isUdpOpen = false; } } else if (args[0].ToLower() == "bind") { //because ipv6 string parsing algorithm is complicated, for now and just in console application using .Net class for it System.Net.IPAddress ip = System.Net.IPAddress.Parse(args[1]); IPv6Address ipv6Address = new IPv6Address(ip.GetAddressBytes()); ushort port = Convert.ToUInt16(args[2]); threadUdpListening = new Thread(() => UDPListenerThread(ipv6Address, port)); threadUdpListening.Start(); } else if (args[0].ToLower() == "send" && args.Length == 4) { System.Net.IPAddress ip = System.Net.IPAddress.Parse(args[1]); IPv6Address ipv6Address = new IPv6Address(ip.GetAddressBytes()); ushort port = Convert.ToUInt16(args[2]); byte[] data = Encoding.UTF8.GetBytes(args[3]); UdpSocket udpClient = new UdpSocket(); udpClient.Connect(ipv6Address, port); udpClient.Send(data, data.Length); udpClient.Close(); } }
public void Close() { //peerList.Clear (); resetTcpAlias(); //hostUser.UIN = 0; groupid = 0; hostUser.PeerConnect = null; if (server != null) { server.Close(); } Log.info(this, "P2PClientNetWork Close--------------------------!"); /*if (listenThread != null) * listenThread.Abort ();*/ }
private static void UDPListenerThread(IPv6Address ipAddress, ushort port) { UdpSocket receiver = new UdpSocket(); receiver.Bind(ipAddress, port); IPv6EndPoint remoteIp = null; isUdpListenerRunning = true; while (isUdpListenerRunning) { if (receiver.Poll(-1, SelectMode.SelectRead)) { byte[] data = receiver.Receive(ref remoteIp); string message = Encoding.ASCII.GetString(data); Console.WriteLine("\n"); Console.WriteLine("{0} bytes from {1} {2} {3}", message.Length, remoteIp.Address, remoteIp.Port, message); Console.WriteLine(">"); } } receiver.Close(); receiver = null; }
public void Close() { m_socket.Close(); }
public void KcpStop() { //enabled = false; kcpClient.Close(); }
void OnDestroy() { socket.Close(); }