I have two PCs connected using winsock (TCP), and before one of them disconnects my program sends a message to let the other end know that the connection is being killed. To do this, I have a very simple bit of code:

Code:
Private Sub BtnDisconnect_Click()
    If Sock1.State = sckConnected Then
        Sock1.SendData ("~disconnecting") 
    End If
    Sock1.Close
End Sub
However, the other computer never receives the message. If I remove "Sock1.Close" it works fine. I don't really have a clue what is happening. Is there any simple way to fix this problem?