0

我正在使用带有FEZ Connect Shield的FEZ Domino。这是我尝试通过以太网端口连接到笔记本电脑上的服务器应用程序的代码:

private const string ServerIPAddress = "192.168.153.206";
private const int port = 2000;

WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,(Cpu.Pin)FEZ_Pin.Digital.Di7, true);         

using(var clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
    IPHostEntry entry = Dns.GetHostEntry(ServerIPAddress);
    IPAddress ipAddress = entry.AddressList[0];
    IPEndPoint serverEndPoint = new IPEndPoint(ipAddress, port);

    Debug.Print("Connecting to server: " + serverEndPoint + ".");

    clientSocket.SendTimeout = 3000;
    clientSocket.Connect(serverEndPoint);

    Debug.Print("Connected to server");

    byte[] msg = Encoding.UTF8.GetBytes("Hello");
    clientSocket.Send(msg);
}

在“clientSocket.Connect(serverEndPoint)”我得到这个异常:

An unhandled exception of type "System.Exception" occurred in GHIElectronics.NETMF.W5100.dll
Additional information: Timeout occurs during connection establishment

当我将笔记本电脑连接到另一台笔记本电脑时,我可以 ping 服务器应用程序,它会响应,所以我相信问题不在服务器应用程序上。

请帮忙

4

1 回答 1

0

我发现了问题,看来你必须给 fez connect shield 一个 IP 地址、子掩码和网关 :)

于 2016-02-17T09:24:55.717 回答