General > Frequently Asked Questions

Nano Client over few servers

(1/2) > >>

acxysty:
Dear all

We are using Nano as client Modbus/TCP and we would like to communicate with several servers without opening and closing the sockets.
Is there a way to do that ?
Regards
TY

support:
Since the Nano-10 only has one socket to act as client you do have to close any existing connection before you can open a connection to another server. However, the socket on the Nano-10 allow you to reuse the socket immediately after it has been closed on one server and use it to connect to another server. So there is not too much latency to switch from one server to another especially if it is over a local area network.

acxysty:
Thank you for your answer.  It works fine the way you describe and we use it a lot.

However we never get the Status(3) flag changing according to connect or non-connect.

Any idea why ?

Regards

support:
The STATUS(3) will return a 1 when a connection has been made. So if the network is busy or network latency is high it may take a little longer to return a 1. You should wait for  STATUS(3) to return a 1 before sending READMODBUS/WRITEMODBUS etc commands.

When you close a socket, there is a bit of house keeping that the network stack need to do to fully close the socket. Only when the socket is fully closed then STATUS(3) returns a zero.

If you do a round-robin connection to each slave quickly then managing the network connection and disconnection is important, otherwise you may encounter situation where the next connection will fail because the last connection is still open.

Attached sample program "ModbusTCPTest.PC6" file is a good example to follow to prevent your program from getting stuck in inability to close a previous connection properly before making a new connection.
 

acxysty:
It works now.
Thank you
Regards

Navigation

[0] Message Index

[#] Next page

Go to full version