VB 中WINSOCK的用法
初学VB 很多问题都看不明白 请高手指点指点 THK U
SEVER我是怎么写的
Private Sub Command1_Click()
Dim maydata As String
Mydata = "你好吗?"
Winsock1.SendData Mydata
End Sub
'发送信息
Private Sub Form_Load()
Winsock1.LocalPort = 5400
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
MsgBox "ok" '确定是否连接成功
End Sub
Private Sub Winsock1_DtatArrival(ByVal bytesTotal As Long)
Dim Mydata As String
Winsock1.GetData Mydata
MsgBox Mydata
End Sub
**************************************
CLIENT 部分
Private Sub Command1_Click()
Dim maydata As String
Mydata = "你好吗?"
Winsock1.SendData Mydata
End Sub
Private Sub Form_Load()
Winsock1.RemoteHost = "***.**.**.*" '我写了我自己电脑的IP
Winsock1.RemotePort = 5400
Winsock1.LocalPort = 0
Winsock1.Connect
End Sub
Private Sub Winsock1_DtatArrival(ByVal bytesTotal As Long)
Dim Mydata As String
Winsock1.GetData Mydata
MsgBox Mydata
End Sub
分别运行后 连接成功了 但是无论我按 SEVER 还是 CLIENT的 SEND 按扭 总是没反映 也不报错 请问是怎么回事啊谢谢~