public virtual void Shutdown(string reason) { LogWrite("Performing shutdown (" + reason + ")"); //#if DEBUG // just send all delayed packets; since we won't have the possibility to do it after socket is closed SendDelayedPackets(NetTime.Now + this.SimulatedMinimumLatency + this.SimulatedLatencyVariance + 1000.0); //#endif try { if (m_socket != null) { // This throws an exception under mono for linux, so we just ingnore it. try { //m_socket.Shutdown(SocketShutdown.Receive); } catch (SocketException) {} m_socket.Close(2); } } finally { m_socket = null; m_isBound = false; } m_shutdownComplete = true; LogWrite("Socket closed"); }
// Callback when the ping method times out private void OnTimeOut(object state) { HasPingCommandTimedOut = true; if (NetworkSocket != null) { NetworkSocket.Close(); } }
public void Dispose() { if (NetworkSocket.Connected) { NetworkSocket.Shutdown(SocketShutdown.Both); NetworkSocket.Disconnect(true); } NetworkSocket.Close(1000); }
public void Disconnect() { try { NetworkSocket.Close(); } catch { } }