A SocketException is thrown by the Socket and Dns classes when an error occurs with the network.
This means that one of the methods of Socket
objects throws SocketException
, therefore you already know its source and the code shpould be something like this:
Socket currentSocket;
try
{
/* Socket stuff with currentSocket */
}
catch (SocketException se)
{
if (ex.ErrorCode == (int)SocketError.ConnectionAborted)
{
//Remove socket from list
ConnectionAborted( currentSocket ); // At his point currentSocket is in scope.
}
}