Hi, I'm trying to connect to a server using BeginConnect and when I specified an incorrect IpAddress or Port I get a SocketException.
The problem is that my try/catch doesn't catch 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 method VS report me the exception and block the program...
How can I handle it?
Thanks Federico