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");
        }
예제 #2
0
 // Callback when the ping method times out
 private void OnTimeOut(object state)
 {
     HasPingCommandTimedOut = true;
     if (NetworkSocket != null)
     {
         NetworkSocket.Close();
     }
 }
예제 #3
0
파일: eSock.cs 프로젝트: gmhacx/NetCore
 public void Dispose()
 {
     if (NetworkSocket.Connected)
     {
         NetworkSocket.Shutdown(SocketShutdown.Both);
         NetworkSocket.Disconnect(true);
     }
     NetworkSocket.Close(1000);
 }
예제 #4
0
 public void Disconnect()
 {
     try
     {
         NetworkSocket.Close();
     }
     catch
     {
     }
 }