diff --git a/Scripts/Misc/SocketOptions.cs b/Scripts/Misc/SocketOptions.cs index 36c6c99d0..2af3571f7 100644 --- a/Scripts/Misc/SocketOptions.cs +++ b/Scripts/Misc/SocketOptions.cs @@ -25,7 +25,6 @@ namespace Server public static void Initialize() { SendQueue.CoalesceBufferSize = CoalesceBufferSize; - SocketPool.InitialCapacity = PooledSockets; EventSink.SocketConnect += new SocketConnectEventHandler( EventSink_SocketConnect ); diff --git a/Server/Main.cs b/Server/Main.cs index 40dcc27e9..427b0f90d 100644 --- a/Server/Main.cs +++ b/Server/Main.cs @@ -242,9 +242,6 @@ namespace Server { } - if ( SocketPool.Created ) - SocketPool.Destroy(); - if ( m_Service ) { Console.WriteLine( "This exception is fatal." ); } else { @@ -342,9 +339,6 @@ namespace Server if( !m_Crashed ) EventSink.InvokeShutdown( new ShutdownEventArgs() ); - if( SocketPool.Created ) - SocketPool.Destroy(); - Timer.TimerThread.Set(); Console.WriteLine( "done" ); @@ -455,8 +449,6 @@ namespace Server ScriptCompiler.Invoke( "Initialize" ); - SocketPool.Create(); - MessagePump ms = m_MessagePump = new MessagePump(); timerThread.Start(); diff --git a/Server/Network/Listener.cs b/Server/Network/Listener.cs index 3473bb666..3f9af0885 100644 --- a/Server/Network/Listener.cs +++ b/Server/Network/Listener.cs @@ -57,7 +57,7 @@ namespace Server.Network private Socket Bind( IPEndPoint ipep ) { - Socket s = SocketPool.AcquireSocket(); + Socket s = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ) try { @@ -98,7 +98,7 @@ namespace Server.Network Console.WriteLine( "Listening: {0}:{1}", ipep.Address, ipep.Port ); } - IAsyncResult res = s.BeginAccept( SocketPool.AcquireSocket(), 0, m_OnAccept, s ); + IAsyncResult res = s.BeginAccept( m_OnAccept, s ); return s; } @@ -145,7 +145,7 @@ namespace Server.Network } try { - listener.BeginAccept( SocketPool.AcquireSocket(), 0, m_OnAccept, listener ); + listener.BeginAccept( m_OnAccept, listener ); } catch ( SocketException ex ) { NetState.TraceException( ex ); } catch ( ObjectDisposedException ) { @@ -183,8 +183,6 @@ namespace Server.Network try { socket.Close(); - - SocketPool.ReleaseSocket( socket ); } catch ( SocketException ex ) { NetState.TraceException( ex ); } diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index 86087dc19..7e23eea3a 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -845,8 +845,6 @@ namespace Server.Network { try { m_Socket.Close(); - - SocketPool.ReleaseSocket( m_Socket ); } catch ( SocketException ex ) { TraceException( ex ); } diff --git a/Server/Network/SocketPool.cs b/Server/Network/SocketPool.cs deleted file mode 100644 index dc4f572f3..000000000 --- a/Server/Network/SocketPool.cs +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * SocketPool.cs - * ------------------- - * begin : May 1, 2002 - * copyright : (C) The RunUO Software Team - * email : info@runuo.com - * - * $Id$ - * - ***************************************************************************/ - -/*************************************************************************** - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - ***************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Net.Sockets; - -namespace Server.Network -{ - public class SocketPool - { - private static bool m_Created = false; - - public static bool Created - { - get { return m_Created; } - } - - private static int m_Misses = 0; - private static int m_InitialCapacity = 32; - - public static int InitialCapacity - { - get { return m_InitialCapacity; } - set { - if ( m_Created ) - return; - - m_InitialCapacity = value; - } - } - - private static Queue m_FreeSockets; - - public static void Create() - { - if ( m_Created ) - return; - - m_FreeSockets = new Queue( m_InitialCapacity ); - - for ( int i = 0; i < m_InitialCapacity; ++i ) - m_FreeSockets.Enqueue( new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ) ); - - m_Created = true; - } - - public static void Destroy() - { - if ( !m_Created ) - return; - - while ( m_FreeSockets.Count > 0 ) - m_FreeSockets.Dequeue().Close(); - - m_FreeSockets = null; - } - - public static Socket AcquireSocket() - { - lock ( m_FreeSockets ) - { - if ( m_FreeSockets.Count > 0 ) - return m_FreeSockets.Dequeue(); - - ++m_Misses; - - for ( int i = 0; i < m_InitialCapacity; ++i ) - m_FreeSockets.Enqueue( new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ) ); - - return m_FreeSockets.Dequeue(); - } - } - - public static void ReleaseSocket( Socket s ) - { - /*if ( s == null ) - return; - - s.Close(); - - lock ( m_FreeSockets ) - m_FreeSockets.Enqueue( s );*/ - } - } -} \ No newline at end of file