我正在使用 VB.NET
所以我有一个每秒广播它自己的IP的服务器
Private Sub IPBroadcastTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IPBroadcastTimer.Tick
BroadcastIP()
End Sub
我是否必须每秒播放一次,以便客户在几分钟或几小时后接收?
如果是这样,我将如何设置服务器来监听登录?
以下是客户端和服务器端发生的情况:
服务器:“每秒广播 IP” > “侦听传入传输” > “接收 3 个字符串[用户名/密码/IP] ” > “检查本地 XML 文件上的用户名和密码有效性” > “向目标 IP 发送确认或拒绝”
客户端:“监听服务器广播” > “接收服务器 IP” > “通过表单发送 3 个字符串:用户名、密码和本地 IP” > “监听服务器的确认或拒绝”
我用它来发送,但听似乎不起作用......
Public EndPoint As New IPEndPoint(IPAddress.Parse("255.255.255.255"), 1001) ''Send destination port
Public EndPoint2 As New IPEndPoint(IPAddress.Any, 2001) ''Receive destination port
Public UserIPEndPoint As New IPEndPoint(IPAddress.Any, 2001)
Public UsernameEndPoint As New IPEndPoint(IPAddress.Any, 2001)
Public PassEndPoint As New IPEndPoint(IPAddress.Any, 2001)
Public Send As New UdpClient(2001) ''Send source port
Public Receive As New UdpClient(1001) '' Receive source port
发送:
Send.Send(IPInBytes, IPInBytes.Length, EndPoint)
接收:
Receive.Receive(UserIPEndPoint)
我该如何解决这个问题?