Ver código fonte

修改接收设置生效

Modbus_TCP
zcn1123 4 anos atrás
pai
commit
cee30de1d3
1 arquivos alterados com 4 adições e 4 exclusões
  1. +4
    -4
      Modbus_communication/Modbus_TCP/TCP_client.cpp

+ 4
- 4
Modbus_communication/Modbus_TCP/TCP_client.cpp Ver arquivo

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



Carregando…
Cancelar
Salvar