I have a N+ with this configuration:
DeviceInfo: HAL build info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC OEM Product codes (vendor, model, SKU): 34, 177, 4097 Serial Numbers (module, system): 00000000000000000000000000000000 0000000000000000 Solution Build Info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC AppDomains: Assemblies: mscorlib,4.2.0.0 Microsoft.SPOT.Native,4.2.0.0 Microsoft.SPOT.Hardware,4.2.0.0 Microsoft.SPOT.Net,4.2.0.0 System,4.2.0.0 Microsoft.SPOT.Hardware.SerialPort,4.2.0.0 Microsoft.SPOT.IO,4.2.0.0 System.IO,4.2.0.0 Microsoft.SPOT.Hardware.Usb,4.2.0.0 Microsoft.SPOT.Hardware.PWM,4.2.0.0 SecretLabs.NETMF.Hardware,4.2.0.0 SecretLabs.NETMF.Diagnostics,4.2.0.0 SecretLabs.NETMF.Hardware.NetduinoPlus,4.2.0.0 Board.THNPD16I16O,1.0.0.0 Gsiot.Server,1.0.0.0 Board.THNPD16I16O.Services,1.0.0.0 Toolbox.NETMF,1.0.0.0 Board.Contracts,1.0.0.0 Board.THNPD16I16O.Contracts,1.0.0.0 Toolbox.NETMF.Hardware,1.0.0.0 Board.Services,1.0.0.0
Snippet Code:
public static Socket Connect(string host, int port, int timeout) { // look up host's domain name to find IP address(es) IPHostEntry hostEntry = Dns.GetHostEntry(host); // extract a returned address IPEndPoint remoteEndPoint = new IPEndPoint(hostEntry.AddressList[0], port); // connect! Debug.Print("connect..."); var connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); connection.Connect(remoteEndPoint); connection.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); connection.SendTimeout = timeout; Debug.Print("connected to... " + remoteEndPoint.ToString()); return connection; }
Walkthrough:
--> N+ is with ethernet cable plugged when initialize
--> N+ has a valid ip address
--> The snippet code is invoked with the following parameters: host: 123.123.123.123, port: 80, timeout 5000
--> The host parameters doesn't exist or is unavailable
Sinthom:
--> The program hangs on the connection.Connect(remoteEndPoint); instruction and doesn't throw an exception.
Why?
Thanks in advance.