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);
}
