in reply to Re^6: session expiry
in thread session expiry

Right. $sock1 did not connect, and you never know about that because you only check whether $sock connects.