EndConnect Exception
I am trying to connect to the server using BeginConnect and when I specified the wrong IpAddress or Port, I get a SocketException.
The problem is my try / catch is not catching the Exception:
private void OnConnect(IAsyncResult result)
{
try
{
socket.EndConnect(result);
status = Status.WaitAck;
socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, onDataReady, null);
}
catch (Exception ex)
{
if (ConnectionError != null)
ConnectionError(this, new OpenWebNetErrorEventArgs(ex));
}
}
When I call the socket.EndConnect VS method, it informs me of the exception and blocks the program ...
How can I handle this?
Thanks Federico
+2
source to share