Windows Phone 7.1 (Mango) – Socket Sample

As some of you might know, I’m currently writing a book called “Windows Phone 7 in Action” with two amazing authors for Manning. We managed to put new sample for Socket to our git repository yesterday. Our small program has the conversational style chat message view which is similar to the SMS view on Windows Phone (Mango) and socket classes ( Tcp Unicast, Udp Unicast and Udp AnySource Multicast). In order to make our code simple, we didn’t add any validation logic in our code. We hope that our sample might help for those who are new to Windows Phone socket programming.

You might say that there are some examples for sockets in MSDN already but one important thing to note is that the author of those samples encourages developers to use ManualResetEvent. It’s so misleading. I don’t really understand why they did that. But all I can do is to give them feedback so I (and a few other MVPs as well) submitted the feedback a few months back but nothing changed until now.

Anyway, let’s get back to our sample code. Here is the folder structure and a bit of details about samples.

Clients

  • ChatTcpUnicast : This sample uses Tcp Unicast so you will have to run the Tcp Server to test the code.
  • ChatUdpAnySourceMulticastClient : This is UdpAnySourceMulticast sample so you don’t need to run any server. It’s just peer-to-peer.
  • ChatUdpUnicast :

Servers

  • TcpSocketServer
  • UdpSocketServer

You can download the full source from this link below.

Githttps://github.com/timothybinkley/Windows-Phone-7-In-Action/tree/master/Chapter09/Socket

Please feel free to let us know if you have any question or anything for improvement. We are sorry that we couldn’t write all those explanations here. If you are interested in detailed explanation, please get our book ”Windows Phone 7 in Action” from Manning. Thanks.

UPDATE: 

Note that I didn’t use appbar which is not bindable and doesn’t have Command.. so you gotta touch twice to send the message .. You may want to replace with this bindable appbar http://www.maxpaulousky.com/blog/archive/2011/01/10/bindable-application-bar-extensions-for-windows-phone-7.aspx

X-Calibre Hackathon – Win Nokia Lumia devices, and $7K USD worth of cash prizes.

My friend “Chris Ismal” from Nokia posted about the event that he and his team are organizing in our Singapore Silverlight Facebook page. This event is called “ X-Calibre Hackathon”. It’s a full day event that developers come and build the application for Windows Phone by using latest Windows Phone 7.5 (mango) features.

You can read the details on their official website. I copied and pasted some informations for you here as well.

Winners will ride away with a trophy unlike any other, and Nokia Lumia devices to the 1st prize winning team, and…

  • 1st prize -$4,000 USD
  • 2nd prize – $2,000 USD
  • 3rd prize – $1,000 USD

The winning apps will also be featured in Nokia’s App Highlights and Amazing Everyday Marketing Campaign!

What is X-Calibre Hackathon?

X-Calibre Hackathon is a one-day Windows Phone application building contest (9am – 6pm) happening on November 19, 2011 where developers compete to create the best WP app using Mango features such as  Metro UI, Live Tiles, Fast App Switching etc.

What is the judging criteria? 

Judging will be done by representatives from Nokia, Microsoft, and the WP Champs.  There will be no criteria weightage.  Judging will simply be based on “the best Windows Phone app that uses Mango features such as Metro UI, Live Tiles, Fast App Switching, and others!”

What are the contest details?

  1. The chosen 60 participants will be divided into 4 groups each stationed at different locations.  Groups will compose of teams with maximum 3 members each team.  In total there will be 20 teams.
  2. Two Windows Phone Champs will be managing and providing technical support to each of the groups.  In total there will be 8 Champs.
  3. The contest will commence at 9:00 am simultaneously throughout the locations.  The Champs will be on-location until 6pm.  Venue is only available until 6:00 pm.  Contest (submission) ends 11:59 pm on the same day.
  4. Bring your own laptop, wifi, and food!5. Contest winners will be announced at the Awarding event in Nokia Singapore (date to be confirmed)

HTC 7 Mozart – C1010009 in updating Windows Phone 7.1 (Mango)

My phone “HTC 7 Mozart” was having problem in updating Windows 7.1 Mango “7.10 (7720)”. I kept on getting “C1010009″ error whenever I tried to update.

After doing some researches and googling a bit, I came to know that it’s because of the USB port. I was using the USB ports which are in front of the system box . So, I switched my phone USB cable to the port at the back of my system box then it works.

If you are also having C1010009 error, please try switching different USB port and try updating again. Please feel free to share if you have any other solution!

Windows Phone 7.1 (Mango) – Tcp Socket acts differently on emulator and device (HTC Mozard)

It’s just a quick post to share one strange behavior that I found when I was using Socket in Windows Phone 7.1. project.

The issue is that when I run this piece of code on device, I always get “SocketError = Success” all the time. I reported about it to Silverlight team but didn’t hear anything yet. Does anyone have experience this issue with socket?

private void Button_Click(object sender, RoutedEventArgs e)
{
            var socket = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream,
                ProtocolType.Tcp);

            var ipAddress = IPAddress.Parse("192.168.10.37"); //This sample is for showing error.. this ip address doesn't count much.
            var args = new SocketAsyncEventArgs();
            args.RemoteEndPoint = new IPEndPoint(ipAddress, 22222);

            args.Completed += (_, evt) => {
                this.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(string.Format("Socket Return Msg : {0}", evt.SocketError));
                });
            };
            socket.ConnectAsync(args);
}

Windows Phone 7 App Submission Now Open!!

I received the newsletter from Windows Marketplace saying that WP7 app submission is open to all registered Windows Phone Marketplace developers. The good thing about it is that you can use one account to submit your apps/games for both the Windows Phone Marketplace and the Xbox LIVE Marketplace. The registration fee is $99 per year.

When I submitted my app, I faced some problems to login but the following steps helped me to solve my problems.

  • Go to xbox.com
  • Sign in using your Marketplace developer credentials
  • Review and accept the Xbox Live Terms of Use agreement
  • Return to App Hub and select My dashboard (Windows Phone 7 or profile). You may need to select this option twice (the first time could give the same behavior, but the second time should work).