Ensuring Immediate TCP Port Release After Closing a TCPServer


When working with TCPServer components, a recently closed connection may leave the local port unavailable for a short period of time. Understanding how the operating system handles socket shutdown helps ensure that TCP ports are released and reused as quickly as possible.

IPWorks components do not have direct control over when the system releases a port. When an IPWorks component closes a TCP connection, the component instructs the operating system to unbind any bound sockets (connections). In the case of a graceful disconnection, that operating system call immediately returns, but it may be some time before the port is ready to bind again. In the case of an immediate disconnection, the operating system call immediately returns, and the port is immediately ready to bind again.

For IPWorks components that utilize TCP to disconnect immediately, the Linger property must be set to false. This will ensure that the port will be ready immediately after the IPWorks component closes a TCP connection.

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.