locked
streamsocket problem in background

    Question

  • Hi,

    I make an app communication with server by using streamsocket. And in some machine, the socket does not work correnctly when the app turn into background. But in my simulator, it works correct in background. What should I do? Thanks.



    • Edited by nowashman Friday, September 21, 2012 4:34 PM
    Friday, September 21, 2012 4:26 PM

Answers

  • This is a good talk on general network troubleshooting tools and issues.

    Debugging connected Windows 8 apps
    TOOL-588T
    Speakers: Raghu Gatta

    Generally, if you provide more specific details on your problem, (error codes, example of undesired network / socket behavior, system that is behaving unexpectedly) the community can usually provide more specific recommendations.


    David Lamb


    Monday, September 24, 2012 5:25 PM
    Moderator

All replies

  • This is a good talk on general network troubleshooting tools and issues.

    Debugging connected Windows 8 apps
    TOOL-588T
    Speakers: Raghu Gatta

    Generally, if you provide more specific details on your problem, (error codes, example of undesired network / socket behavior, system that is behaving unexpectedly) the community can usually provide more specific recommendations.


    David Lamb


    Monday, September 24, 2012 5:25 PM
    Moderator
  • Dear David,

    void Dispatcher::ReceiveMessageLoop(DataReader^ reader, StreamSocket^ socket, bool* loop)

    {

            if (*loop == false)

                    return;

            // Read first header.

        //

            task<unsigned int>(reader->LoadAsync(headerSize)).then([this, reader, socket, loop] (unsigned int size)

        {

            if (size < headerSize)

            {

                            //exceptionMessage = L"reader load task_canceled (size < headerSize)";

                // The underlying socket was closed before we were able to read the whole data.

                cancel_current_task();

            }

    When my app turn into background for about 20 seconds, then "(size < headerSize)" occurs, and the receiving loop ends.

    Thank you.

    Saturday, September 29, 2012 1:11 PM
  • Hi All,

    I know this has been a long time. I'm now facing a similar issue with WP8.1 Bluetooth background task. The app crashes after it writes into the socket several times. I wonder if you had a solution for your issue that could be useful to me as well. Thanks

    Wednesday, April 29, 2015 1:31 AM