version 3.9.0, add PIEthernet::NoDelay parameter

This commit is contained in:
2023-03-21 10:14:05 +03:00
parent df82102798
commit 0cd1206f94
3 changed files with 22 additions and 7 deletions

View File

@@ -203,8 +203,7 @@ bool PIEthernet::init() {
piCoutObj << "Can`t create socket," << ethErrorString();
return false;
}
if (params[PIEthernet::ReuseAddress]) ethSetsockoptBool(sock, SOL_SOCKET, SO_REUSEADDR);
if (params[PIEthernet::Broadcast]) ethSetsockoptBool(sock, SOL_SOCKET, SO_BROADCAST);
applyParameters();
applyTimeouts();
applyOptInt(IPPROTO_IP, IP_TTL, TTL());
// piCoutObj << "inited" << path();
@@ -814,6 +813,14 @@ PIIODevice::DeviceInfoFlags PIEthernet::deviceInfoFlags() const {
}
void PIEthernet::applyParameters() {
if (sock == -1) return;
if (params[PIEthernet::ReuseAddress]) ethSetsockoptBool(sock, SOL_SOCKET, SO_REUSEADDR);
if (params[PIEthernet::Broadcast]) ethSetsockoptBool(sock, SOL_SOCKET, SO_BROADCAST);
if (params[PIEthernet::NoDelay] && (type() == TCP_Client)) ethSetsockoptBool(sock, IPPROTO_TCP, TCP_NODELAY, true);
}
void PIEthernet::clientDeleted(PIObject * o) {
clients_mutex.lock();
clients_.removeOne((PIEthernet *)o);