Frank Schmidt - 2013-08-16

At first i want to thank you for this very useful library. I really appreciate your work.

In my application I use WriteCoilRequest to write some bits to a PLC and it works great. But it can happen that the network connection just isn't available and the WriteCoilRequest ends up in a timeout.

I would like to timeout the request after 500 milliseconds and therefore I use .setTimout(500) on the TCPMasterConnection. But it seems to have no effect at all.
My guess is that the library hangs on m_Socket = new Socket(m_Address, m_Port); in the TCPMasterConnection.java and doesn't get to set the timeout at all.

Could it be better to replace this:

m_Socket = new Socket(m_Address, m_Port);
setTimeout(m_Timeout);

with this?

m_Socket = new Socket();
m_Socket.setSoTimeout(m_Timeout);
m_Socket.connect(new InetSocketAddress(m_Address, m_Port), m_Timeout);

Just to timeout the socket in all cases after the set timeout value. Probably this is wrong and I am doing something wrong. But i am not able to build the library by myself so I would really like to her someone else opinion one this. Thank you.