這些程式碼到底哪裡出錯了(編號:1202)

下面是我用Winsock寫的發訊程式
Cilent 端
物件:
winsock1 'winsock1物件
command1 '連線的
command2 '中斷的
command3 'Send Data 的
text1  '對方的IP
text2  '傳出去的訊息
程式碼:
Private Sub Command1_Click()
Dim IP As Long
IP = Val(Text1.Text)
Winsock1.RemoteHost = IP
Winsock1.RemotePort = 5240
Winsock1.LocalPort = 0
Winsock1.Connect
End Sub
Private Sub Command2_Click()
Winsock1.Close
End Sub
Private Sub Command3_Click()
Dim mydata As String
mydata = Text2.Text
Winsock1.SendData mydata
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub
Server端
物件:
Winsock1 'winsock物件
程式碼:
Private Sub Form_Load()
Winsock1.LocalPort = 5240
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mydata As String
Winsock1.GetData mydata
If mydata = "close" Then
Winsock1.Close
Unload Me
Else
MsgBox mydata, 48, "VB"
End If
End Sub
但當我按下傳送(command3)時
確出現"對所要求的交易或要求而言,通訊協定(protocol)不適合或
連線狀態有誤"這到底是怎一回事?
但有時後又可正常執行,這到底是怎一回事?
請大家幫幫忙好嗎?
Thanks a lot