我在3个不同的位置有3台不同的计算机,我需要构建一个可以使用vb.net控制这3台计算机的软件,我的基本需求是在我的服务器系统上播放视频,我需要这3台计算机要同时播放相同的视频,我如何使用vb.net发送和接收无线数据
答案 0 :(得分:0)
您可以将视频上传到任何视频托管网站,然后使用此代码向计算机发送消息(使用公布的IP地址):
Public Class MessageReciever
Dim Listener As New TcpListener(5534) 'or any unused port
Dim Client As TcpClient
Private Sub MessageReciever_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Listener.Stop()
End Sub
Private Sub MessageReciever_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
Listener.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim message As String
Dim nStart As Integer
Dim nLast As Integer
If Listener.Pending = True Then
message = ""
Client = Listener.AcceptTcpClient()
Dim reader As New StreamReader(Client.GetStream())
While reader.Peek > -1
message &= Convert.ToChar(reader.Read()).ToString
End While
If message.Contains("</>") Then
nStart = InStr(message, "</>") + 4
nLast = InStr(message, "<\>")
message = Mid(message, nStart, nLast - nStart)
End If
End If
If message = "playVideo" then
Process.start("http://youtube.com/watch?yourvideo") 'opens website in default browser
End If
End Sub
End Class
导入它告诉你的所有内容。
如果您将此软件放在要播放视频的计算机上,然后将以下代码放在主计算机上,您希望控制其他人:
Option Explicit On
Public Class MessageSender
Dim client As TcpClient
Private Sub PlayVidButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayVidButton.Click
Try
client = New TcpClient(computer ur controllings public ip, 5534) 'you can get your public ip @ portforward.com and make sure the port here is the same as the one entered for the listener in the other form
Dim writer As New StreamWriter(client.GetStream())
writer.Write("playVideo")
writer.Flush()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
我希望这有助于解决您的问题。