Home Forums Support GetConnection() In IOS Not Giving Exception

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3409
    Anonymous
    Inactive

    Hello.

    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.

    Thanks for any help…

    Andrew

    #3410
    Anonymous
    Inactive

    Heya Andrew,

    Thank-you for the bug report. Might you be so kind an create an issue on our bug tracker, https://bitbucket.org/MarcF/networkcomms.net/issues/new.

    We had a similar issue with android so the two may be related.

    Kind regards,
    Marc

    #3411
    Anonymous
    Inactive

    Hello Marc.

    Thanks for the reply.

    I have created an issue for this bug.

    Andrew

    #3680
    Anonymous
    Inactive

    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.

    static bool IsServerAvailable(string IPOfServer, int PortNumberToTry)
    {
    bool SomethingListeningOnPort = false;

    try
    {
    System.Net.Sockets.Socket sock = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
    System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
    sock.Connect(IPOfServer, PortNumberToTry);
    if (sock.Connected == true) // Port is in use and connection is successful
    SomethingListeningOnPort = true;
    sock.Close();

    }
    catch (System.Net.Sockets.SocketException)
    {
    SomethingListeningOnPort = false;
    }

    return SomethingListeningOnPort;
    }

    Andrew

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.