wp8 streamsocket

Building on previous StreamSocket-related posts http://babaandthepigman.wordpress.com/2012/04/07/streamsocket-example-c-metro/ and http://babaandthepigman.wordpress.com/2012/10/12/metro-app-and-kinect-voice-control/ which use socket code for Windows Store apps and for Windows 8 desktop I decided to try the code on Windows Phone 8. I have recently bought a Lumia 920 so am now in a position to try it out.

Just to recap the ‘Streamsocket example c# metro’ post contains code to send/receive messages between Windows Store applications. Since these APIs are also available from the Windows 8 desktop the ‘metro app and kinect voice control’ post reused that code to communicate between a Windows Store app and Windows 8 desktop app (WPF).

These APIs are also available on Windows Phone 8 so I decided to try it out with me new lumia. I simply pasted the code from the other project into a c# windows phone xaml application using Visual Studio 2012. I took the xaml and the code behind and the only re-jigging required was as follows:

  • Layed out the content grid on the page to fit on the phone
  • Altered some code referencing the Dispatcher as the interface is slightly different on the phone
  • Changed the Message dialog code.

This worked as expected and I was able to create a session between my windows 8 tablet and the lumia:

wp8_stream socket



This was just a quick experiment and I’m feeling bad about not refactoring into a Portable Class library but hopefully will get around to that soon.

Solution is here http://sdrv.ms/T2quLL

Tagged ,

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.