From cee30de1d3ebe934dd4ec6d838adcdce5f4edb4e Mon Sep 17 00:00:00 2001 From: zcn1123 <2363211205@qq.com> Date: Tue, 1 Sep 2020 14:50:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E6=94=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modbus_communication/Modbus_TCP/TCP_client.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modbus_communication/Modbus_TCP/TCP_client.cpp b/Modbus_communication/Modbus_TCP/TCP_client.cpp index 2a0a9a2..a5ed0da 100644 --- a/Modbus_communication/Modbus_TCP/TCP_client.cpp +++ b/Modbus_communication/Modbus_TCP/TCP_client.cpp @@ -101,10 +101,10 @@ SOCKET Init_client(string IP, unsigned int Port_number) cout << "尝试连接TCP从站失败" << endl; } cout << "连接TCP从站成功" << endl; - //TIMEVAL timeout; - //timeout.tv_sec = 2000; //ms - //timeout.tv_usec = 0; //us - //setsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(struct timeval));//设置接收超时时间 + TIMEVAL timeout; + timeout.tv_sec = 2000; //ms + timeout.tv_usec = 0; //us + setsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(struct timeval));//设置接收超时时间 return ClientSocket; }