Set/reset connection state at creation time and upon closing connections.