checking socket connect state before sending final packet and calling shutdown (to...