title: How to speed up slow / laggy Windows Phone 7 (WP7) TCP Socket transmit?
body: <p>Recently, I started using the System.Net.Sockets class introduced in the Mango release of WP7 and have generally been enjoying it, but have noticed a disparity in the latency of transmitting data in debug mode vs. running normally on the phone.</p>
  
  <p>I am writing a "remote control" app which transmits a single byte to a local server on my LAN via Wifi as the user taps a button in the app. Ergo, the perceived responsiveness/timeliness of the app is highly important for a good user experience.</p>
  
  <p>With the phone connected to my PC via USB cable and running the app in debug mode, the TCP connection seems to transmit packets as quickly as the user taps buttons.</p>
  
  <p>With the phone disconnected from the PC, the user can tap up to 7 buttons (and thus case 7 "send" commands with 1 byte payloads before all 7 bytes are sent.) If the user taps a button and waits a little between taps, there seems to be a latency of 1 second.</p>
  
  <p>I've tried <strong>setting Socket.NoDelay to both True and False, and it seems to make no difference.</strong></p>
  
  <p>To see what was going on, I used a packet sniffer to see what the traffic looked like. </p>
  
  <ul>
  <li><p>When the phone was connected via USB to the PC (which was using a Wifi connection), each individual byte was in its own packet being spaced ~200ms apart. </p></li>
  <li><p>When the phone was operating on its own Wifi connection (disconnected from USB), the bytes still had their own packets, but they were all grouped together in bursts of 4 or 5 packets and each group was ~1000ms apart from the next.</p></li>
  </ul>
  
  <p>btw, Ping times on my Wifi network to the server are a low 2ms as measured from my laptop.</p>
  
  <p>I realize that buffering "sends" together probably allows the phone to save energy, but <strong>is there any way to disable this "delay"?</strong> The responsiveness of the app is more important than saving power.</p>