Commit 68a44a00 authored by Pavel Vainerman's avatar Pavel Vainerman

(UTCStream): поменял реализацию функции isConnected()

parent 9d7db391
...@@ -542,8 +542,8 @@ void MBTCPMultiMaster::help_print( int argc, const char* const* argv ) ...@@ -542,8 +542,8 @@ void MBTCPMultiMaster::help_print( int argc, const char* const* argv )
cout << endl; cout << endl;
cout << " Настройки протокола TCP(MultiMaster): " << endl; cout << " Настройки протокола TCP(MultiMaster): " << endl;
cout << "--prefix-persistent-connection 0,1 - Не закрывать соединение на каждом цикле опроса" << endl; cout << "--prefix-persistent-connection 0,1 - Не закрывать соединение на каждом цикле опроса" << endl;
cout << "--prefix-checktime - период проверки связи по каналам (<GateList>)" << endl; cout << "--prefix-checktime msec - период проверки связи по каналам (<GateList>)" << endl;
cout << "--prefix-ignore-timeout - Timeout на повторную попытку использования канала после 'reopen-timeout'. По умолчанию: reopen-timeout * 3" << endl; cout << "--prefix-ignore-timeout msec - Timeout на повторную попытку использования канала после 'reopen-timeout'. По умолчанию: reopen-timeout * 3" << endl;
cout << endl; cout << endl;
cout << " ВНИМАНИЕ! '--prefix-reopen-timeout' для MBTCPMultiMaster НЕ ДЕЙСТВУЕТ! " << endl; cout << " ВНИМАНИЕ! '--prefix-reopen-timeout' для MBTCPMultiMaster НЕ ДЕЙСТВУЕТ! " << endl;
cout << " Смена канала происходит по --prefix-timeout. " << endl; cout << " Смена канала происходит по --prefix-timeout. " << endl;
......
...@@ -496,15 +496,5 @@ void ModbusTCPMaster::forceDisconnect() ...@@ -496,15 +496,5 @@ void ModbusTCPMaster::forceDisconnect()
bool ModbusTCPMaster::isConnection() const bool ModbusTCPMaster::isConnection() const
{ {
return tcp && tcp->isConnected(); return tcp && tcp->isConnected();
#if 0
if( !tcp )
return false;
if( tcp->poll({0, 5}, Poco::Net::Socket::SELECT_READ) )
return (tcp->available() > 0);
return false;
#endif
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -95,15 +95,25 @@ void UTCPStream::create(const std::string& hname, int port, timeout_t tout_msec ...@@ -95,15 +95,25 @@ void UTCPStream::create(const std::string& hname, int port, timeout_t tout_msec
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UTCPStream::isConnected() bool UTCPStream::isConnected()
{ {
//return ( Poco::Net::StreamSocket::sockfd() > 0 ); return ( Poco::Net::StreamSocket::sockfd() > 0 );
/*
try try
{ {
return ( Poco::Net::StreamSocket::peerAddress().addr() != 0 ); // Вариант 1
//return ( Poco::Net::StreamSocket::peerAddress().addr() != 0 );
// Варинт 2
return ( Poco::Net::StreamSocket::peerAddress().port() != 0 );
// Вариант 3
// if( poll({0, 5}, Poco::Net::Socket::SELECT_READ) )
// return (tcp->available() > 0);
} }
catch( Poco::Net::NetException& ex ) catch( Poco::Net::NetException& ex )
{ {
} }
return false; return false;
*/
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
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