private void Disconnect() { Debuger.Log(LOG_TAG_MAIN, "Disconnect()"); KHDebugerGUI.RemoveDbgGUI("FSPClient"); m_IsRunning = false; if (m_ThreadReceive != null) { m_ThreadReceive.Interrupt(); m_ThreadReceive = null; } if (m_ThreadSend != null) { m_ThreadSend.Interrupt(); m_ThreadSend = null; } if (m_Socket != null) { m_Socket.Close(); m_Socket = null; } if (m_UseGSDK) { GSDKManager.Instance.EndSpeed(); } m_HostEndPoint = null; }
private async void UDPListen() { try { var anyEP = new IPEndPoint(0, 0); var socket = new Socket(listen.AddressFamily, SocketType.Dgram, ProtocolType.Udp); socket.Bind(listen); udpClient = MyStream.FromSocket(socket); while (true) { var r = await udpClient.ReadFromAsyncR(64 * 1024, anyEP); Task.Run(() => HandleUdpReceiveResult(r)).Forget(); } } catch (Exception e) { Logger.exception(e, Logging.Level.Warning, "UDP listener stopped"); } finally { udpClient?.Close(); udpClient = null; } }
protected override void OnStop() { base.OnStop(); udpClient?.Close(); udpClient = null; }