I'm making a tiny little program for chatting over a network (almost like winpopup) but it doesnt work...

Code:
Function Connect(sendIP As String) As Boolean

    Form1.Winsock1.Close
    Form1.Winsock2.RemoteHost = sendIP
    Form1.Winsock2.RemotePort = 1066
    Form1.Winsock2.Connect
    Connect = True

End Function

private sub cmdSend_Click()

Dim D As Boolean
D = Connect(txtIP)
If D = False Then
    Exit Sub
End If

If Form1.Winsock1.State = 0 Then
    Form1.Winsock1.Listen
End If

If Form1.Winsock2.State = sckConnected Then
    Form1.Winsock2.SendData txtMess
    Form1.Winsock2.Close
Else
    MsgBox "could not send."
    Form1.Winsock2.Close
End If

end sub
What's wrong with this? when i run the program it says "could not send" because the state of the winsock is "Connecting" not "Connected" as i want it to be...