程序調試中當程序運行到:
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地址。
排查原因即可。
---------------------------------------隨筆,以便日后查看。