关于C#使用Nmodbus4中设置TCP Master时,设置ReadTimeout报错;

程序调试中当程序运行到:

string ipAddress = “10.0.0.69”; //use TCP for example
int tcpPort = 502;
TcpClient tcpClient = new TcpClient();
ModbusIpMaster IpMaster = ModbusIpMaster.CreateIp(tcpClient);
IpMaster= ModbusIpMaster.CreateIp(tcpClient);
IpMaster.Transport.Retries = 0; //don't have to do retries

IpMaster.Transport.ReadTimeout = com1.Com_ReadTimeOut; 

此时会产生错误提示:不允许对非连接的套接字执行此操作。

产生原因:

以太网链路有问题:ping不上对应的IP地址。

排查原因即可。

---------------------------------------随笔,以便日后查看。

posted @ 2020-04-14 10:27  仄仄123  阅读(2783)  评论(0)    收藏  举报