Browse Source

修改接收设置生效

Modbus_TCP
zcn1123 4 years ago
parent
commit
cee30de1d3
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      Modbus_communication/Modbus_TCP/TCP_client.cpp

+ 4
- 4
Modbus_communication/Modbus_TCP/TCP_client.cpp View File

@@ -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;
}



Loading…
Cancel
Save