This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Get Error 60 When Closing and Opening a TCP Connection on the Same Local Port

Updated Jan 11, 2019

Reported In

Software

  • LabVIEW

Issue Details

I am using a real time controller and I am opening a TCP connection on a specific local port.  After I close the connection, I immediately reopen it on the same local port.  The TCP Open Connection VI returns: Error 60 occurred at TCP Open Connection in MyVI.vi.  My TCP code looks similar to the snippet below.
Why does this occur, and how can I fix it?

Solution

This condition is expected behavior for TCP/IP stack which is commonly implemented on different operating systems, VxWorks and Linux RT included.  The behavior is known as the TCP TIME-WAIT state, and it sets a port number to be blocked for a period of about one minute after closing its connection.  This behavior allows any packets for the connection still in the network to be either received or time out before a new connection is opened on the port, which prevents messages for an old connection being received by a new connection.

Generally, it is best to let the operating system choose the local port number.  If you need to use a specific local port, you must allow several minutes between closing the connection and opening it again to allow for the TIME-WAIT state to complete. In case of Linux RT targets (such as cRIO-906x and 903x), if you need to immediately reuse the same TCP port, you can modify lvrt.conf file by adding the following token:
SocketSetReuseAddr=True
The lvrt.conf file is saved in folder /files/etc/natinst/share/ .

WAS THIS ARTICLE HELPFUL?

Not Helpful