'本例须要一个按扭,一个winsock控件(Microxoft Winsock Control 6.0 (SP6))
Private Sub Form_Load()
Winsock1.Protocol = sckUDPProtocol '使用udp协议
Winsock1.RemoteHost = 192.168.0.1 '设置远程IP
Winsock1.RemotePort = 8765 '设置远程端口
Winsock1.Bind 8765 '绑定8765端口
End Sub
Private Sub Command1_Click()
Winsock1.SendData Text1.Text '发送消息
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock1.GetData s '接收消息
Text1.Text = s '消息导入到文本框中
End Sub
'===============================自己===============================
Private Sub Form_Load()
Winsock1.Protocol = sckUDPProtocol '使用udp协议
Winsock1.RemoteHost = 192.168.0.2 '设置远程IP
Winsock1.RemotePort = 8765 '设置远程端口
Winsock1.Bind 8765 '绑定8765端口
End Sub
Private Sub Command1_Click()
Winsock1.SendData Text1.Text '发送消息
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock1.GetData s '接收消息
Text1.Text = s '消息导入到文本框中
End Sub
'===============================别人===============================