kurt69
Well-known member
Hi, got a general problem here, not sure how to fix it.. i've hardly dealt with this sought of stuff before.
So I have this UDP broadcasting feature in my application right, it has both the send and receive code built in. Now it's the receive code I'm having trouble with. What I want it to do is to store the receive data (which is a string) in a listbox, while storing the IPEndPoint that sent the data in an array. Here's what I have so far:
Also how can I split anyEP.ToString. For example say it is equal to 10.1.1.2:1880 and I only want the 10.1.1.2. THANKS IN ADVANCED BIG TIME!!!!
So I have this UDP broadcasting feature in my application right, it has both the send and receive code built in. Now it's the receive code I'm having trouble with. What I want it to do is to store the receive data (which is a string) in a listbox, while storing the IPEndPoint that sent the data in an array. Here's what I have so far:
VB.NET:
Try
Dim listener As New Sockets.UdpClient(11000)
Dim anyEP As New IPEndPoint(IPAddress.Parse("0.0.0.0"), 11000)
lstHostlist.Items.Insert(0, "Waiting for broadcast")
Do While Not done
Dim rcvdHost As Byte() = listener.Receive(anyEP)
Dim h As Integer
Dim hostIP As String = anyEP.ToString
For h = 0 To UBound(hostsBd)
If hostsBd(h) = hostIP Then
hostsBd(h + 1) = hostIP
lstHostlist.Items.Add(Encoding.ASCII.GetString(rcvdHost, 0, rcvdHost.Length))
End If
Next
Loop
Finally
End Try
Also how can I split anyEP.ToString. For example say it is equal to 10.1.1.2:1880 and I only want the 10.1.1.2. THANKS IN ADVANCED BIG TIME!!!!