I'm experiencing unexpected behaviour from ActiveSync, when establishing socket connections with a Windows Mobile 6 Classic emulator.
When the emulator is not cradled (and thus not connected to ActiveSync), System.Net.Sockets.Socket.
Connect() properly throws a SocketException, when I try to connect to non existant IP/port combinations.
When the emulator is cradled (and connected to ActiveSync) however, I can connect to arbitrary IP/port combinations, without getting a SocketException.
Can this be fixed? I need the SocketException, to reliably check wether a server is available or not.
The development environment is:
Windows XP Professional SP3
Visual Studio 2008 SP1
.NET Compact Framework 3.5 SP1
Windows Mobile 6 Classic Emulator
Device Emulator Manager 9.0
string host = "some valid ip or hostname";
string port = "some valid port";
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var ip = Dns.GetHostEntry(host).AddressList.First();
var ipendpoint = new IPEndPoint(ip, Convert.ToInt32(port));