Question Thousands of first chance SocketExceptions - Hangs app

LycaonX

New member
Joined
Aug 11, 2010
Messages
3
Programming Experience
10+
I have a game server coded in .NET that hosts around 100 players and about 300 NPC connections. The server has gone through years of refinement and I have it in pristine working order when dealing with player connections. By that I mean it is not uncommon for us to go four months without restarting the server app after processing hundreds of thousands of player connects and disconnects.

My problem is that the NPC client application hosts dozens of connections, each on their own thread, and the application is still not as stable as the server. When the NPC app crashes and all of those 50 or so connections drop all at once, my server just hangs. I ran the server in the IDE and repeated the process, and what apparently is happening is that thousands and thousands of first chance SocketExeceptions are happening at the rate of hundreds per second. Each Socket is encapsulated completely inside a Client class that makes liberal use of Try / Catch blocks due to the nature of asynchronous sockets, and any time any SocketException happens, an internal class variable is marked so that absolutely no more BeginReceive or BeginSend calls are allowed, then the socket is closed and an event is called that allows the main server class to properly finish cleanup and dispose of the Client class.

I understand what FIRST CHANCE means, and I have Googled and every answer I can find states "Just ignore it" but I can't ignore it. Whether in Debug or Release mode, it brings the server to it's knees and I have to force stop it because it can't process any new connections.

I'm at my wit's end here. Can any of you provide something I can try or track down? Since .NET 1.1 I have been able to solve my own problems but this one is killing me, and all of my game playing subscribers.
 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
If you're getting thousands of exceptions thrown then I can only assume that, after catching one such exception, you are immediately attempting another action that causes the same exception to be thrown. You need to identify where the exception is being thrown and how your code is reaching that point over and over.
 
Top Bottom