소스 검색

修改接收设置生效

Modbus_TCP
zcn1123 4 년 전
부모
커밋
cee30de1d3
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. +4
    -4
      Modbus_communication/Modbus_TCP/TCP_client.cpp

+ 4
- 4
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;
}



불러오는 중...
취소
저장