Active property of the socket-based component is true, though I know that connection has been closed by the server. Why so?
Active property, when set, indicates that connection was successful and the component was ready to perform its actions. However if the connection was lost on socket level, Active property can still be True. This is because on socket level there's no way to be notified that the connection is closed. The only way to check actual connection state is to attempt to send something and get an error in case the connection has been closed. This is by design (of TCP/IP).
Your code should always be ready to handle unexpected disconnections and other network errors and reconnect if needed.