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,

            var ipAddress = IPAddress.Parse(""); //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));

Leave a Reply