I have the following code:
try
{
mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, serverPort);
mainSocket.Bind(ipEndPoint);
mainSocket.Listen(MAX_CONNECTIONS);
mainSocket.BeginAccept(new AsyncCallback(serverEndAccept), mainSocket);
OnNetworkEvents eventArgs =
new OnNetworkEvents(true, "Listening for Connection");
OnUpdateNetworkStatusMessage(this, eventArgs);
}
catch (SocketException e)
{
// add code here
}
catch (ObjectDisposedException e)
{
// add code here
}
How do I test the code's SocketException
given the server is listening successfully all of the time?