Tony Stock - 2017-03-02

Hi,

I'm looking into some existing code that reads from a Modbus device using jamod 1.2

For each read cycle (once a second) it opens a new TCPMasterConnection performs the reads and then closes it.

Is this a reasonable implementation?

It also closes the sockets in the TCPMasterConnection using reflection to get the m_socket variable

field = connClass.getDeclaredField("m_Socket");
field.setAccessible(true);
final Object socket = field.get(conn);
f (socket instanceof Socket)
{
socket.close()
}
- I'm not sure why , maybe the sockets associated with TCPMasterConnection are not closed properly?

Regards

Tony