I have a Xamarin IOS app which uses NetworkCommsDotNet to communicate with a server. When the IOS app tries to connect to the server and the server is not running I expect to get an exception at the GetConnection() call but I don’t and instead the call just hangs. When I test this from a client running on Windows I get a ‘ConnectionSetupException’ at the GetConnection call, should I be getting this exception from the same call from my IOS app as well ?
On IOS if the establishIfRequired parameter is set to false in the GetConnection() call then, if the server is not available, the call returns immediately with no exception but obviously I get an exception on any subsequent network operation.
When the server is running everything connects and works as expected. I am using version 3 of NetworkcommsDotNet.
For anyone else who has come across this problem here is my current workaround (until the version comes out with a fix for this issue). I call the following method prior to trying to connect with networkcomms.net. Only if this method tells me something is listening do I try and connect with networkcomms.net library.
System.Net.Sockets.Socket sock = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
if (sock.Connected == true) // Port is in use and connection is successful
SomethingListeningOnPort = true;