Does $sslready evaluate to $true? Going straight to sockclose is indicative that it's an ssl problem.