diff --git a/src/Socket2.cpp b/src/Socket2.cpp index 6d6e8a85bf58fdc4db386a633675b3466eb65059..0729b04fd013ad77c887ca08767595797e463bc9 100644 --- a/src/Socket2.cpp +++ b/src/Socket2.cpp @@ -292,6 +292,13 @@ void Socket2::get_device_property() /*----- PROTECTED REGION ID(Socket2::get_device_property_after) ENABLED START -----*/ // Check device property data members init + transform(iOMultiplexing.begin(), iOMultiplexing.end(), iOMultiplexing.begin(), ::tolower); + if (iOMultiplexing == "sleep") { + multiplexing = SLEEP; + } else { + multiplexing = SELECT; + } + transform(protocol.begin(), protocol.end(), protocol.begin(), ::tolower); if (protocol == "udp") { proto = UDP; @@ -299,13 +306,6 @@ void Socket2::get_device_property() proto = TCP; } - transform(iOMultiplexing.begin(), iOMultiplexing.end(), iOMultiplexing.begin(), ::tolower); - if (iOMultiplexing == "sleep") { - multiplexing = SLEEP; - } else { - multiplexing = SELECT; - } - if (port <= 0 || port > 65535) init_error = "Invalid port"; @@ -522,7 +522,6 @@ void Socket2::write(const Tango::DevVarCharArray *argin) goto error; /* Continue if multiplexing == SLEEP */ } else { /* bytes_written < 0 */ - check_state(false); goto error; } } @@ -541,6 +540,7 @@ void Socket2::write(const Tango::DevVarCharArray *argin) return; error: + check_state(false); sleep(tout); timeout: Tango::Except::throw_exception( @@ -735,7 +735,7 @@ void Socket2::close() if(input_len + output_len) { - WARN_STREAM << " Bytes dropped: " << input_len << " input, " + WARN_STREAM << " Bytes dropped: " << input_len << " (" << data.size() << ") input, " << output_len << " output" << endl; } @@ -779,12 +779,12 @@ void Socket2::_read(size_t bytes_to_read) goto error; /* Continue if multiplexing == SLEEP */ } else { /* bytes_readed < 0 */ - check_state(true); goto error; } } return; error: + check_state(false); sleep(tout); timeout: Tango::Except::throw_exception( @@ -843,6 +843,7 @@ void Socket2::check_state(bool forcing) set_state(Tango::INIT); set_status("Reconnecting due: " + mesg); + DEBUG_STREAM << "Reconnecting due: " << mesg << endl; close(); resolve(); diff --git a/src/Socket2.h b/src/Socket2.h index 06bf3348fc954a43b877837c4b78cb1695652b69..c69e2842c6f7f9e9dbbd2121930401f3a433e68a 100644 --- a/src/Socket2.h +++ b/src/Socket2.h @@ -75,12 +75,8 @@ class Socket2 : public TANGO_BASE_CLASS // Add your own data members string init_error; - enum {TCP, UDP} proto; - int fd; int conn_state; - sockaddr_in sa; - socklen_t sa_len; enum event_type {READ, WRITE}; @@ -91,6 +87,11 @@ class Socket2 : public TANGO_BASE_CLASS enum {SLEEP, SELECT} multiplexing; timeval timeout_timeval, tout; + + enum {TCP, UDP} proto; + + sockaddr_in sa; + socklen_t sa_len; /*----- PROTECTED REGION END -----*/ // Socket2::Data Members // Device property data members diff --git a/src/Socket2.xmi b/src/Socket2.xmi index e8453a8383116f1f686be4a87839ec35bda32258..eea2cdaff932c879bd83f257efb5a16f4a3db100 100644 --- a/src/Socket2.xmi +++ b/src/Socket2.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="Socket2" pogoRevision="9.7"> - <description description="" title="" sourcePath="/home/alessio.bogani/Sources/git-trees/linkstabilizer/deps/socket2/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="" title="" sourcePath="/home/alessio/Sources/git-trees/4uhv/deps/socket2/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at elettra.eu> - Alessio Igor Bogani <alessio.bogani" author="Alessio Igor Bogani <alessio.bogani" emailDomain="elettra.eu>" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="Socket" manufacturer="none" reference=""/> </description>