Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect socket under lock screen on Windows Phone
    text
    copied!<p>I try to write application that connects to a server with a sockets. All works fine, but when application is running under lock screen the socket can't connect (it is waiting while lock screen is removed).</p> <p>Device connected to a PC, so WiFi should not have an impact (auto turn-off) for battery-saving</p> <p>How to reproduce (code below):</p> <p>1) Start application and wait 30 seconds. In Debug windows you will see:</p> <pre><code>Try to connect at 15:35:08 Connected at 15:35:08 </code></pre> <p>2) Start application, lock the screen and wait 30 seconds. In Debug windows you will see:</p> <pre><code>Try to connect at 15:36:07 Connected at 15:36:42 </code></pre> <p>So, during lock screen nothing happens, socket is frozen</p> <p>This is my code my:</p> <pre><code> public MainPage() { InitializeComponent(); PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; DnsEndPoint dnsEndPoint = new DnsEndPoint("stackoverflow.com", 80); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); SocketAsyncEventArgs socketOperationEventArguments = new SocketAsyncEventArgs(); socketOperationEventArguments.RemoteEndPoint = dnsEndPoint; socketOperationEventArguments.Completed += (s, e) =&gt; { if (e.SocketError == SocketError.Success &amp;&amp; e.ConnectSocket.Connected) { Debug.WriteLine("Connected at " + DateTime.Now.ToLongTimeString()); } }; DispatcherTimer Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(10) }; Timer.Tick += (s, e) =&gt; { Debug.WriteLine("Try to connect at " + DateTime.Now.ToLongTimeString()); socket.ConnectAsync(socketOperationEventArguments); Timer.Stop(); }; Timer.Start(); } </code></pre> <p>EDIT:</p> <p>Send data is also not working under lock screen. Log:</p> <pre><code>Try to connect at 10:18:39 Connected at 10:18:39 Try to send at 10:18:40 Send data at 10:18:40 Try to send at 10:18:41 Send data at 10:18:41 Try to send at 10:18:42 Send data at 10:18:42 Try to send at 10:18:43 Try to send at 10:18:44 Try to send at 10:18:45 Try to send at 10:18:46 Try to send at 10:18:47 Try to send at 10:18:48 Try to send at 10:18:49 Send data at 10:18:50 Send data at 10:18:50 Send data at 10:18:50 Send data at 10:18:50 Send data at 10:18:50 Send data at 10:18:50 Send data at 10:18:50 Try to send at 10:18:51 Send data at 10:18:51 Try to send at 10:18:52 Send data at 10:18:52 </code></pre> <p>Screen was locked from 10:18:43 to 10:18:50</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload