Commit 82739c72 authored by Pavel Vainerman's avatar Pavel Vainerman

(Modbus): попытка включить keepAlive для соединения

parent 197713a2
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
--confile test.xml \ --confile test.xml \
--mbtcp-name MBMaster1 \ --mbtcp-name MBMaster1 \
--smemory-id SharedMemory \ --smemory-id SharedMemory \
--dlog-add-levels info,crit,warn,level4,level3 \ --dlog-add-levels info,crit,warn,level4,level3,level9 \
--mbtcp-set-prop-prefix \ --mbtcp-set-prop-prefix \
--mbtcp-filter-field rs \ --mbtcp-filter-field rs \
--mbtcp-filter-value 5 \ --mbtcp-filter-value 5 \
--mbtcp-gateway-iaddr 127.0.0.1 \ --mbtcp-gateway-iaddr 192.168.1.42 \
--mbtcp-gateway-port 2048 \ --mbtcp-gateway-port 2048 \
--mbtcp-recv-timeout 5000 \ --mbtcp-recv-timeout 5000 \
--mbtcp-force-disconnect 1 \ --mbtcp-force-disconnect 1 \
......
...@@ -314,6 +314,7 @@ void ModbusTCPMaster::reconnect() ...@@ -314,6 +314,7 @@ void ModbusTCPMaster::reconnect()
// TCPStream (const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0) // TCPStream (const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0)
tcp = new ost::TCPStream(iaddr.c_str(),ost::Socket::IPV4,536,true,500); tcp = new ost::TCPStream(iaddr.c_str(),ost::Socket::IPV4,536,true,500);
tcp->setTimeout(replyTimeOut_ms); tcp->setTimeout(replyTimeOut_ms);
tcp->setKeepAlive(true);
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
...@@ -365,6 +366,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port ) ...@@ -365,6 +366,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
{ {
tcp = new ost::TCPStream(iaddr.c_str(),ost::Socket::IPV4,536,true,500); tcp = new ost::TCPStream(iaddr.c_str(),ost::Socket::IPV4,536,true,500);
tcp->setTimeout(replyTimeOut_ms); tcp->setTimeout(replyTimeOut_ms);
tcp->setKeepAlive(true);
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment