Main Site Documentation

Failing to connect to an IP address


#1

I am trying to connect to an IP address on the LAN from my chipwokx board

I am using the following code:

    public void ConnectToServer()
    {
        client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        IPHostEntry entry = Dns.GetHostEntry(serverIp);
        IPAddress ipAddress = entry.AddressList[0];
        IPEndPoint endPoint = new IPEndPoint(ipAddress, port);
        client.Connect(endPoint);    // Throws an exception
    }

It hangs for about 2-3 minutes then thrown
exception 10035.

Am I missing something simple here?

Here is the entire error stack:
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::poll [IP: 0000] ####
#### System.Net.Sockets.Socket::Poll [IP: 0011] ####
#### System.Net.Sockets.Socket::Connect [IP: 0029] ####
#### OPI_POS.Classes.Client::ConnectToServer [IP: 0028] ####
#### OPI_POS.Program::Main [IP: 0089] ####
#### SocketException ErrorCode = 10035
#### SocketException ErrorCode = 10035
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10035
#### SocketException ErrorCode = 10035

my firewall is off !!!


#2

Have you tried to ping the device from another computer?

Are you using a static IP address or DHCP?

Have you configured your network interface in MFDeploy?


#3

Test connecting to the server from a PC first on the same network.
For example if the address of the server is x.x.x.x and the TCP port is 80

Open command prompt cmd.exe the run this command

telnet x.x.x.x 80


#4

[quote]Have you tried to ping the device from another computer?

Are you using a static IP address or DHCP?

Have you configured your network interface in MFDeploy?[/quote]

I am using DHCP, and i did configure my network interface in MFDeploy.


#5

Do as Joe says or make a simple C# console app that will do exactly the same as your net mf app but on PC.


#6

Has your chipworkx retrieved an IP address from DHCP successfully?


#7

it did.


#8

guys i found the problem simple thing, the ip adress of the server was wrong ???
thanx for the quick response.


#9

Glad to hear it’s all working for you now.